|
8 years atrás | |
---|---|---|
.. | ||
.npmignore | 8 years atrás | |
LICENSE | 8 years atrás | |
README.md | 8 years atrás | |
index.js | 8 years atrás | |
package.json | 8 years atrás |
YAML loader for webpack. Converts YAML to a valid JSON. If you want a JS Object, chain it with json-loader.
npm install yaml-loader
Simplest case would be:
var json = require("json!yaml!./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
// applicatin.js
const actualFilename = require(`file?name=[name].json!./../data/${file}.yaml`);
window.fetch(actualFilename).then(res => {
// ...
});