json-x-loader

0.3.0 • Public • Published

json-x-loader

Webpack JSON transformer

npm i --save-dev json-x-loader

In 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"
    }
}

Package Sidebar

Install

npm i json-x-loader

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

6.16 kB

Total Files

5

Last publish

Collaborators

  • alanlu1023