JSON Strip Loader
JSON loader for Webpack, with support for keys stripping, useful in isomorphic builds for storing secrets in JSON files.
The main use case for this loader comes when using a JSON settings file containing some secret keys, that you want to use on the server but don't want to make public on the client.
Let's say your
settings.json looks like this:
environment: 'production'secret: 'password'AWS:secret: 'password'
Now you can use
json-strip-loader as a drop-in replacement for
json-loader on your server webpack configuration:
And you can strip out the secrets on your client webpack configuration:
$ npm install --save json-strip-loader
moduleexports =module:rules:test: /\.json$/use: 'json-strip-loader' // Simply load the fileuse: 'json-strip-loader?key=secret' // Remove the keys names `secret` from the filesuse: 'json-strip-loader?key=secret&deep=false' // Remove `secret` only from the root leveluse: 'json-strip-loader?keys=secret,keys=server' // Remove the keys names `secret` and `server` from the files
webpack --module-bind 'json=json-strip-loader'
- strip-keys - An utility for removing specific keys from an object.
MIT © Fabio Spampinato