Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generate-json-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-json-webpack-plugin

Webpack plugin to generate a custom JSON asset

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

generate-json-webpack-plugin

npm version

webpack plugin to generate a custom JSON asset

Installation

npm install generate-json-webpack-plugin

Usage

// webpack.config.js
const GenerateJsonPlugin = require('generate-json-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    // ...
    new GenerateJsonPlugin('my-file.json', {
      foo: 'bar',
    }),
  ],
  // ...
};

This will create a file my-file.json in webpack's output directory, with contents:

{ "foo": "bar" }

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:

new GenerateJsonPlugin(
  'my-file.json',
  { foo: 'bar', one: 'two' },
  (key, value) => {
    if (value === 'bar') {
      return 'baz';
    }
    return value;
  },
  2
);

my-file.json will contain:

{
  "foo": "baz",
  "one": "two"
}

Keywords

FAQs

Package last updated on 18 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc