transform-json-webpack-plugin
Webpack plugin to generate a JSON asset file.
Install
npm install --save-dev transform-json-webpack-plugin
Options
Name | Type | Description |
---|---|---|
filename |
{String} |
Output file name(may include path) |
object |
{Object} |
Object to add to output file or the properties you wish to modify |
source |
{String} |
Path to an existing JSON file to extend (optional) |
Usage
In your webpack.config.js
instantiate the plugin.
const TransformJson = ; moduleexports = // webpack configuration // ... plugins: // json configuration ;
Here is a basic example that creates a mainfest.json
file in your output directory:
webpack.config.js
moduleexports = output: path: 'build/' // ... plugins: filename: 'manifest.json' value: gundam: 'wing-zero' ;
That will generate a file that looks like this:
manifest.json
Here is a basic example that creates a production deployment version of your package.json
file in your output directory:
webpack.config.js
moduleexports = output: path: 'build/' // ... plugins: filename: 'package.json' source: __dirname + "/package.json" object: devDependencies: {} scripts: "start": "node index.js" ;
That will generate a file that looks like this:
package.json