{"id":20059,"library":"generate-json-webpack-plugin","title":"generate-json-webpack-plugin","description":"Webpack plugin (v2.0.0) that generates a custom JSON asset in webpack's output directory. Requires webpack 5 (dropped webpack 4 support in v2.0.0). Use it to create JSON files from JavaScript objects during the webpack build process. Supports custom JSON.stringify replacer and space parameters for formatting. Simpler than using webpack's built-in assets approach or write-file-webpack-plugin for JSON output. Niche but focused; no active recent development (last release 2022), but stable for webpack 5 users.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/elliottsj/generate-json-webpack-plugin","tags":["javascript","webpack"],"install":[{"cmd":"npm install generate-json-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add generate-json-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add generate-json-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS require is the documented usage. No ESM version available; if using ESM, you'd need to use createRequire or dynamic import.","wrong":"import GenerateJsonPlugin from 'generate-json-webpack-plugin';","symbol":"GenerateJsonWebpackPlugin","correct":"const GenerateJsonPlugin = require('generate-json-webpack-plugin');"},{"note":"First argument must be the filename string, second is the JSON object.","wrong":"new GenerateJsonPlugin({ key: 'value' })","symbol":"GenerateJsonWebpackPlugin","correct":"new GenerateJsonPlugin('file.json', { key: 'value' })"},{"note":"Third argument must be a replacer function or null, fourth is space (number/string). Common mistake is swapping arguments.","wrong":"new GenerateJsonPlugin('file.json', { key: 'value' }, 'space')","symbol":"GenerateJsonWebpackPlugin","correct":"new GenerateJsonPlugin('file.json', { key: 'value' }, replacer, space)"}],"quickstart":{"code":"const GenerateJsonPlugin = require('generate-json-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  mode: 'production',\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new GenerateJsonPlugin('manifest.json', {\n      version: '1.0.0',\n      description: 'Generated with generate-json-webpack-plugin',\n    }),\n  ],\n};","lang":"javascript","description":"Creates a JSON asset (manifest.json) with static object in webpack's output."},"warnings":[{"fix":"Upgrade to webpack 5 or pin to v1.x if using webpack 4.","message":"v2.0.0 drops webpack 4 support. Only webpack 5 is supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Consider using webpack's built-in asset modules or a custom plugin.","message":"Plugin is no longer actively maintained. Last release was 2 years ago.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure first argument is a string: new GenerateJsonPlugin('file.json', { ... })","cause":"Filename passed as object instead of string.","error":"TypeError: First argument must be a string"},{"fix":"Run 'npm install generate-json-webpack-plugin --save-dev'.","cause":"Package not installed or missing from dependencies.","error":"Cannot find module 'generate-json-webpack-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}