javascriptajaxwebpackwebpack-3

generate JSON file during Webpack build


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",


Solution

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

    enter image description here