Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 622
Ivan Avatar asked May 04 '26 18:05

Ivan


1 Answers

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

enter image description here

like image 102
Ivan Avatar answered May 06 '26 06:05

Ivan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!