3

I'm using Webpack to build my assets for Chrome Extension. Usually in the /dist you should have some JS files, some HTML files, and manifest.json

Previously I had this file created somewhere and using 'copy-webpack-plugin' I simply copied that to the /dist folder, like this:

enter image description here

But now, I need to generate this manifest.json dynamically. I need to make AJAX request, get some data needed in the manifest.json, generate this file, and then put it in the /dist folder.

I'm familiar with Node.js and I know how to get AJAX data. I may be able to google how to generate JSON file. But how can I connect this Node.js app with Webpack build I have no idea. Should I use a plugin?

Please help me with this. I'm using "webpack": "^3.0.0",

Ivan
  • 852
  • 1
  • 12
  • 29
  • 1
    copy-webpack-plugin has a transform attribute, you can use that to write whatever you want in this file https://github.com/webpack-contrib/copy-webpack-plugin#transform – lukas-reineke Apr 18 '18 at 13:40
  • @lukas-reineke yes, that helped, thanks – Ivan Apr 19 '18 at 11:26

1 Answers1

6

This is how I managed to implement this using transform method:

enter image description here

Ivan
  • 852
  • 1
  • 12
  • 29