0.5.0 • Published 6 years ago
esm-yaml-loader v0.5.0
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
0.5.0
6 years ago