A Webpack loader that converts YAML files into JavaScript objects or JSON strings, using the `yaml` library for parsing. The current stable version is 0.9.0, released with support for Webpack 5+ and Node.js 20+. It offers options like `asJSON` for JSON output, `asStream` for parsing multi-document YAML streams, and `namespace` for extracting specific sub-trees. Unlike alternatives like js-yaml-loader, this loader leverages the more modern `yaml` package and is actively maintained. Release cadence is irregular, with major version bumps for breaking changes.
npm install yaml-loaderVerified import paths — ran on the pinned version, not inferred.
Configures Webpack to import YAML files as JavaScript objects using yaml-loader.
Upgrade to Webpack 5 and Node.js 20 or later.
Set `{ asJSON: true }` option if you need JSON output.Some YAML files parsed as valid by js-yaml may now be invalid; review your YAML files and update if needed.
Output is no longer multiline or tab-indented; if you need prettified JSON, chain another loader or use `asJSON` option and format yourself.
Upgrade Node.js to at least 12.13.
Use either `options` in config or query parameters, not both, to avoid confusion.
Do not combine `asStream` with `namespace`; they are mutually exclusive.
Add module rule in webpack.config.js: { test: /\.ya?ml$/, use: 'yaml-loader' }Run: npm install --save-dev yaml
Configure the loader in webpack.config.js and use static imports instead.
Use: { use: { loader: 'yaml-loader', options: { asJSON: true } } }