mirror of https://gitee.com/antv-l7/antv-l7
f7e5376b7d | ||
---|---|---|
.. | ||
node_modules/.bin | ||
.npmignore | ||
LICENSE | ||
README.md | ||
index.js | ||
package.json |
README.md
yaml-loader for webpack
YAML loader for webpack. Converts YAML to a valid JSON. If you want a JS Object, chain it with json-loader.
Installation
npm install yaml-loader
Usage
Simplest case would be:
var json = require("json-loader!yaml-loader!./file.yml");
// => returns file.yml as javascript object
This loader is also useful for getting a valid JSON from YML. For example:
// webpack.config.js
module: {
loaders: [
{
test: /\.yaml$/,
include: path.resolve('data'),
loader: 'yaml',
},
],
}
and then
// application.js
const actualFilename = require(`file?name=[name].json!./../data/${file}.yaml`);
window.fetch(actualFilename).then(res => {
// ...
});