1

I have

plugins: [
   new webpack.DefinePlugin({consts: require(`./development.json`)})
]

in my webpack.config.js. Config is read once on webpack start, if I change anything in development.json I need to halt the webpack process and run it again.

Is there any way to track file changes for webpack? I don't see anything in sources

deathangel908
  • 8,601
  • 8
  • 47
  • 81
  • You can find an answer here https://stackoverflow.com/questions/31472096/watch-webpack-config-js-and-re-run-webpack-command-in-response-to-a-file-change – Andrii Golubenko May 14 '19 at 11:33
  • This doesn't differ from restarting container manually, I want my code to fire a callback that reevaluates require. The solution in the answer assumes that we restart the whole build. In my case project build like 2 minutes. I don't wanna wait every time for a few minutes when only a small part of project changes. – deathangel908 May 14 '19 at 16:41
  • Why you couldn't import `./development.json` directly in your code? You can add `json-loader` to your webpack config and import `.json` files like `.js`. – Andrii Golubenko May 14 '19 at 18:30
  • Good point, I run some code against strings in development.json, I don't want those code and constants to be exposed to frontend. I also import different json files depending if I run production or development build – deathangel908 May 14 '19 at 21:03
  • You should find another solution instead of using `webpack.DefinePlugin`, because you can't apply changes only for this plugin without running build for all application. – Andrii Golubenko May 15 '19 at 10:27

0 Answers0