json-x-loader
v0.3.0
Published
Webpack JSON transformer
Maintainers
Readme
json-x-loader
Webpack JSON transformer
npm i --save-dev json-x-loaderIn your webpack configuration:
rules: [{
test: /\.json$/,
use: ['json-x-loader?exclude=bar+baz']
}]Then, when you load a json file:
{
"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:
rules: [{
test: /\.json$/,
use: ['json-x-loader?exclude=foo.*+*.zilly']
}]with
{
"foo": {
"a": "b",
"c": {
"d": "e"
}
},
"baz": {
"zilly": "hoo",
"zonk": "patwang"
},
"donkeykong": {
"zilly": "silly",
"foreally": "dealy"
}
}yields
{
"foo": {},
"baz": {
"zonk": "patwang"
},
"donkeykong": {
"foreally": "dealy"
}
}