tettusud / merge-jsons-webpack-plugin

This plugin is used to merge json files into single json file,using glob or file names
https://npmjs.com/package/merge-jsons-webpack-plugin
Apache License 2.0
36 stars 20 forks source link

The emitted json file is not picked up by subsequent webpack plugins #68

Closed GorvGoyl closed 2 years ago

GorvGoyl commented 3 years ago

json file emiited by this plugin is not picked up by other plugins like zip-webpack-plugin or compression-webpack-plugin. It used to work in webpack 4 but not in v5.

Code Snippet:

  const manifest = ["src/manifest.json"];
    manifest.push("src/manifest.chrome.json");

new MergeJsonWebpackPlugin({
      files: manifest,
      output: {
        fileName: "manifest.json",
      },
    }),

new ZipPlugin({ filename: `notion-boost_${browser}.zip` }),
"merge-jsons-webpack-plugin": "^2.0.0-alpha",
"webpack": "^5.14.0",
"zip-webpack-plugin": "^4.0.1"
aarthishuba commented 3 years ago

@GorvGoyl could you give me little bit more info or a quick example to check the issue? How do you refer the json file emitted in other plugin? from new ZipPlugin snippet you provided I can not get the context.

gorbeia commented 3 years ago

This simple project reproduces the issue. file.json is generated but it is not included in the zip.

merge-jsons-zipplugin.zip

gorbeia commented 3 years ago

I have created a pull request to emit the assets in Webpack 5: https://github.com/tettusud/merge-jsons-webpack-plugin/pull/72

aarthishuba commented 2 years ago

@gorbeia thank you for the pull request. I have changed the compilation hook to compilation.hooks.additionalAssets which is more opt and is backward compatible with version 4. Please take a look and in case if you think otherwise, please update.