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