generate-json-webpack-plugin
webpack plugin to generate a custom JSON asset
Installation
npm install generate-json-webpack-plugin
Usage
// webpack.config.jsconst GenerateJsonPlugin = ; moduleexports = // ... plugins: // ... 'my-file.json' foo: 'bar' // ...;
This will create a file my-file.json
in webpack's output directory, with contents:
You may optionally pass 'replacer' and 'space' arguments as the 3rd and 4th arguments, which will be passed to JSON.stringify
to customize the JSON output:
'my-file.json' foo: 'bar' one: 'two' { if value === 'bar' return 'baz'; return value; } 2;
my-file.json
will contain: