esm-yaml-loader
v0.5.0
Published
YAML loader for webpack (converts YAML to JSON)
Downloads
6
Readme
esm-yaml-loader for webpack
ES Module YAML loader for webpack. Converts YAML to an ES Module. This is a fork of yaml-loader
.
Installation
npm install esm-yaml-loader
Usage
Simplest case would be:
// Import tree shakeable identifiers from yaml
import * as obj from 'esm-yaml-loader!./file.yml'
// or the default export for variable identifiers that aren't valid ES6
import obj from 'esm-yaml-loader!./file.yml'
This loader is also useful for getting a valid JSON from YML. For example:
// webpack.config.js
module: {
loaders: [
{
test: /\.ya?ml$/,
loader: 'esm-yaml-loader',
},
],
}
and then
// application.js
import(`./../data/${file}.yaml`).then(res => {
// ...
})
License
MIT (http://www.opensource.org/licenses/mit-license.php)