1. js-yaml-loader
YAML loader for webpack
js-yaml-loader
Package: js-yaml-loader
Created by: wwilsman
Last modified: Fri, 06 May 2022 19:52:42 GMT
Version: 1.2.2
License: MIT
Downloads: 215,501
Repository: https://github.com/wwilsman/js-yaml-loader

Install

npm install js-yaml-loader
yarn add js-yaml-loader

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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin