Webpack 5 plugin that merges multiple JSON files into a single output file during the build process. Version 6.2.1 is current, with a stable release cadence. Supports glob patterns for file selection, custom merge functions, optional output minification, and transformation hooks. Differentiates from simple file concatenation by performing deep merge with customizable merge strategy, and integrates directly as a webpack plugin. Requires webpack ^5.0.0 and Node >=12.20.0. Ships TypeScript definitions.
npm install merge-json-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack config that merges common.json and overrides.json into manifest.json, with optional version injection and minification.
Upgrade to webpack 5 and Node >=12.
Use 'MergeJsonPlugin' instead of 'MergeJsonWebpackPlugin'.
Use webpack's context option instead of passing cwd to the plugin.
Use 'files' array instead, or ensure your transform/merge function handles order.
Ensure transform always returns an object or null; if returning a promise, it must resolve to a valid object.
Avoid mutating objects inside mergeFn; always return a new object.
Run `npm install -D merge-json-webpack-plugin`.
Use `const MergeJsonPlugin = require('merge-json-webpack-plugin');`.Update webpack to version 5: `npm install -D webpack@5`.
Check that all file paths are correct and relative to webpack context or the plugin's cwd.