https://github.com/cag/json-x-loader
Webpack JSON transformer
https://github.com/cag/json-x-loader
json webpack
Last synced: about 2 months ago
JSON representation
Webpack JSON transformer
- Host: GitHub
- URL: https://github.com/cag/json-x-loader
- Owner: cag
- License: mit
- Created: 2017-06-22T17:07:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-05T23:14:22.000Z (over 8 years ago)
- Last Synced: 2025-10-05T12:55:12.149Z (9 months ago)
- Topics: json, webpack
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-x-loader
Webpack JSON transformer
```bash
npm i --save-dev json-x-loader
```
In your webpack configuration:
```js
rules: [{
test: /\.json$/,
use: ['json-x-loader?exclude=bar+baz']
}]
```
Then, when you load a json file:
```json
{
"foo": 1,
"bar": 2,
"baz": 3
}
```
Webpack will emit only `{"foo":1}` and exclude the `bar` and `baz` keys.
You can also use wildcards and deep keys. For example:
```js
rules: [{
test: /\.json$/,
use: ['json-x-loader?exclude=foo.*+*.zilly']
}]
```
with
```json
{
"foo": {
"a": "b",
"c": {
"d": "e"
}
},
"baz": {
"zilly": "hoo",
"zonk": "patwang"
},
"donkeykong": {
"zilly": "silly",
"foreally": "dealy"
}
}
```
yields
```json
{
"foo": {},
"baz": {
"zonk": "patwang"
},
"donkeykong": {
"foreally": "dealy"
}
}
```