{"id":15628035,"url":"https://github.com/sibiraj-s/merge-json-webpack-plugin","last_synced_at":"2025-04-28T19:41:56.794Z","repository":{"id":42525413,"uuid":"279299239","full_name":"sibiraj-s/merge-json-webpack-plugin","owner":"sibiraj-s","description":"﹛ Webpack plugin to merge multiple json files into one ﹜","archived":false,"fork":false,"pushed_at":"2024-09-03T16:43:20.000Z","size":1710,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T06:46:20.487Z","etag":null,"topics":["json","json-merge","webpack-plugin"],"latest_commit_sha":null,"homepage":"https://npm.im/merge-json-webpack-plugin","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sibiraj-s.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sibiraj-s"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-07-13T12:40:50.000Z","updated_at":"2024-09-03T16:43:23.000Z","dependencies_parsed_at":"2024-10-20T14:21:04.591Z","dependency_job_id":null,"html_url":"https://github.com/sibiraj-s/merge-json-webpack-plugin","commit_stats":{"total_commits":140,"total_committers":5,"mean_commits":28.0,"dds":0.0714285714285714,"last_synced_commit":"7bb6c7e8070db0db83126e145cd8e0219d2ca297"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibiraj-s%2Fmerge-json-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibiraj-s%2Fmerge-json-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibiraj-s%2Fmerge-json-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibiraj-s%2Fmerge-json-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sibiraj-s","download_url":"https://codeload.github.com/sibiraj-s/merge-json-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251378736,"owners_count":21580049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-merge","webpack-plugin"],"created_at":"2024-10-03T10:20:35.296Z","updated_at":"2025-04-28T19:41:56.733Z","avatar_url":"https://github.com/sibiraj-s.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sibiraj-s"],"categories":[],"sub_categories":[],"readme":"# merge-json-webpack-plugin\n\n[![Tests](https://github.com/sibiraj-s/merge-json-webpack-plugin/workflows/Tests/badge.svg)](https://github.com/sibiraj-s/merge-json-webpack-plugin/actions)\n[![License](https://badgen.net/github/license/sibiraj-s/merge-json-webpack-plugin)](https://github.com/sibiraj-s/merge-json-webpack-plugin)\n[![Version](https://badgen.net/npm/v/merge-json-webpack-plugin)](https://npmjs.com/merge-json-webpack-plugin)\n[![Node Version](https://badgen.net/npm/node/merge-json-webpack-plugin)](https://npmjs.com/merge-json-webpack-plugin)\n[![Webpack Version](https://badgen.net/badge/webpack/%3E=5/orange)](https://webpack.js.org/)\n\n\u003e Webpack plugin to merge multiple json files into one\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sibiraj-s/merge-json-webpack-plugin\"\u003e\n    \u003cimg width=\"200\" height=\"200\" src=\"./assets/webpack.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Getting Started\n\n### Installation\n\n```bash\nnpm i -D merge-json-webpack-plugin\n# or\nyarn add --dev merge-json-webpack-plugin\n```\n\n### Usage\n\n```js\n// webpack.config.js\nconst MergeJsonPlugin = require('merge-json-webpack-plugin');\n\nmodule.exports = {\n  plugins: [\n    new MergeJsonPlugin({\n      force: false,\n      groups: [\n        {\n          files: [\n            'common-manifest.json',\n            'firefox-manifest.json'\n          ],\n          transform: (outputJson) =\u003e outputJson,\n          to: 'manifest.json',\n        },\n        {\n          pattern: '*.json', // glob. see https://github.com/mrmlnc/fast-glob\n          to: 'merged-[contenthash].json',\n        },\n      ],\n    }),\n  ],\n};\n```\n\n### Options\n\n- **cwd**[`string`] - The directory, an absolute path, for resolving files. Defaults to webpack [context](https://webpack.js.org/configuration/entry-context/#context)\n\n- **groups**[`array`] - Files to merge and destination path\n\n  - **files**[`string[]`] - Array of files, path resolved relative to `cwd`.\n  - **pattern**[`string[]`] or [`string`] - [[Fast-Glob](https://github.com/mrmlnc/fast-glob)] pattern matching. The order of merge is not guarenteed.\n  - **transform**[`function`] - A function to modify the merged json contents. The return json value is written to the output file. If the function returns a promise, it will be awaited.\n  - **to**[`string`]: Destination path to write the files to.\n  - **globOptions**[`GlobOptions`] - Options to foward to `fast-glob` when glob is used otherwise ignored. See https://github.com/mrmlnc/fast-glob#options-3.\n\n- **minify**[`boolean`] - Minify the output json. Enabled by default in production mode.\n\n- **mergeFn**[`function`] - A function used to merge two objects. Defaults to `Object.assign`.\n\n```js\n// webpack.config.js\nconst MergeJsonPlugin = require('merge-json-webpack-plugin');\nconst _ = require('loadsh');\n\nconst customizer = (objValue, srcValue) =\u003e {\n  if (_.isArray(objValue)) {\n    return objValue.concat(srcValue);\n  }\n};\n\nconst merge = (object, other) =\u003e {\n  return _.mergeWith(object, other, customizer);\n};\n\nmodule.exports = {\n  plugins: [\n    new MergeJsonPlugin({\n      mergeFn: merge,\n    }),\n    new MergeJsonPlugin({\n      mergeFn: (prev, current) =\u003e Object.assign(prev, current),\n    }),\n  ],\n};\n```\n\n- **force**[`boolean`] - Overwrites files already in compilation.assets (usually added by other plugins/loaders). Disabled by default.\n\n- **globOptions**[`GlobOptions`] - Options to foward to `fast-glob` when glob is used otherwise ignored. See https://github.com/mrmlnc/fast-glob#options-3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibiraj-s%2Fmerge-json-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsibiraj-s%2Fmerge-json-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibiraj-s%2Fmerge-json-webpack-plugin/lists"}