YAML loader for webpack
npm install js-yaml-loaderJS-YAML loader for webpack.
yarn add js-yaml-loader
Webpack documentation on using loaders.
Using the loader inline:
`` javascript`
import doc from 'js-yaml-loader!./file.yml';
// => returns a javascript object. see https://github.com/nodeca/js-yaml
Or using the loader via Webpack configuration (recommended):
` javascript`
// webpack.config.js
module: {
rules: [{
test: /\.yaml$/,
use: 'js-yaml-loader',
}]
}
Use safeLoad
instead of load.
Set safe to false to allow unsafe types to load, such as regularundefined
expressions, functions, and .
The iterator
option passed to safeLoadAll and loadAll. Applies iterator to each
document if specified.
Any other options are passed directly to to safeLoad or load as theoptions
parameter.
yaml-loader loads YAML files
as _JSON_ and is commonly used in conjuction with json-loader.
In contrast, this loader loads YAML files as JavaScript objects using the
un-eval library. This allows YAML value
types otherwise disallowed in JSON such as Infinity, RegExp, Function`,
etc. See js-yaml's supported YAML types