UNPKG

1.29 kBMarkdownView Raw
1YAML Loader
2===========
3
4YAML loader for [webpack](https://webpack.github.io).
5
6
7Installation
8------------
9
10```
11npm install --save-dev yml-loader
12```
13
14Usage
15-----
16
17```js
18// webpack.config.js
19
20module.exports = {
21 module: {
22 loaders: [
23 {
24 test: /\.yml$/,
25 loader: 'yml'
26 }
27 ]
28 }
29};
30```
31
32Multiple document loading
33-------------------------
34
35By adding a `multiDocument` option will make this possible.
36
37```yaml
38%YAML 1.2
39---
40doc: 1
41---
42doc: 2
43...
44```
45
46
47Blacklisting keys
48-----------------
49
50When passed a `keysToRemove` query (`Array` of `String`s) to remove keys from the loader output.
51
52Given input file:
53```yaml
54development:
55 public_key: "this is needed on the client"
56 private_key: "should be restricted to server"
57prod:
58 public_key: "also needed on the client"
59 private_key: "missile launch codes ¯\_(ツ)_/¯"
60```
61And this loader config:
62```js
63// webpack.config.js under module.exports.module:
64loaders: [
65 {
66 test: /\.ya?ml$/,
67 loader: 'yml',
68 query: {
69 // debug: true, // enable to display removed keys
70 keysToRemove: ['private_key', ],
71 },
72 },
73],
74```
75Will output:
76```js
77{
78 development: { public_key: 'this is needed on the client' },
79 prod: { public_key: 'also needed on the client' }
80}
81```
82
83License
84-------
85[MIT](LICENSE)