I've relatively new to Vue and the web ecosystem as a whole.
I've been building a small app and decided that I wanted to use YAML to store data instead of JSON mainly so that I could use comments.
I tried both of these YAML parsers:
- https://github.com/nodeca/js-yaml (attempted to install via NPM)
- https://github.com/edus44/vue-cli-plugin-yaml (attempted to install via the Vue GUI accessed with
vue ui)
However both had the same issue when I ran vue serve:
error in ./assets/data.yaml
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> #im a comment
| foo: "hello"
| bar: "world"
I'm fairly certain this is valid YAML...here's what my YAML file looks like:
#im a comment
foo: "hello"
bar: "world"
Here is how I tried to import it:
import data from "./assets/data.yaml"
I tried following the instructions at the URL that the error pointed to (https://webpack.js.org/concepts#loaders) but was immediately lost because:
- I don't have a webpack.config.js in my project (it was setup automatically for me via vue-cli)
- The format
const path = require('path');doesn't appear to work in a Vue project?
Both of the YAML parsers and the webpack page assume a lot of prerequisite knowledge that I don't have and further Googling as only confused me more :(
Any pointers would be greatly appreciated!