JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 104693
  • Score
    100M100P100Q150223F
  • License MIT

YAML loader for webpack

Package Exports

  • js-yaml-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-yaml-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

js-yaml-loader for Webpack

JS-YAML loader for webpack.

Installation

yarn add js-yaml-loader

Usage

Webpack documentation on using loaders.

Using the loader inline:

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):

// webpack.config.js
module: {
  rules: [{
    test: /\.yaml$/,
    use: 'js-yaml-loader',
  }]
}

Loader options

safe (boolean) (default=true)

Use safeLoad instead of load. Set safe to false to allow unsafe types to load, such as regular expressions, functions, and undefined.

iterator (function) (default=undefined)

The iterator option passed to safeLoadAll and loadAll. Applies iterator to each document if specified.

...options

Any other options are passed directly to to safeLoad or load as the options parameter.

Difference from yaml-loader

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

License

MIT