You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Watch for webpack config changes in watch mode #15
Current behavior:
I'm not sure if this was discussed before, but it's one of the pain point for me in webpack workflow.
When config / config's dep is updated — hot reloadable server (or watch mode) must be restarted manually. Usually this hot reloadable server is not stand-alone process, but part of the bigger task or even lives inside docker container. And in case of config related change — the only way to pick this up is to restart everything.
Expected/desired behavior:
It'd be cool if webpack could track such changes and rebuild everything from scratch w/o killing current process.
What is the motivation / use case for changing the behavior?
It'll make easier:
work on webpack config setup
work w/ loader's configs, eg postcss plugin's options (js vars etc)
Minimum - document how to achieve it outside of the cli. I guess it depends on the overall goals and priority. I expect v1 would be more or less what it is right now and you can build more features in v1.1 and so on.
I'd expect the same. So far, did not have time to look deeper into the already available options, but if this is in there, for sure will be part of v1. Otherwise, I'd agree with you by adding this to a v1.1 milestone
@ev1stensberg, does this apply to hot-module-reloading / webpack-dev-server? I'm looking for a solution to reset Webpack so it'll pick up the new configuration, and have HMR communicate this change appropriately (likely, a "you must manually refresh to pick up latest changes" type message).
How do we enable this in that scenario; is it as simple as watching the files that modify Webpack configuration? How does one use that without causing all watched files to incite a Webpack reset?
webpack-cli -w -s will refresh everytime you save. I can see that this is actually for the webpack config itself. Insecure if this can be done on the CLI side of things.
Activity
[-]Watch for webpack config changes in watch mode[/-][+]Feature: Watch for webpack config changes in watch mode[/+]DanielaValero commentedon Jan 4, 2017
@ev1stensberg, @pksjce what you guys think, should this be part of our roadmap to v1 ?
bebraw commentedon Jan 4, 2017
Minimum - document how to achieve it outside of the cli. I guess it depends on the overall goals and priority. I expect v1 would be more or less what it is right now and you can build more features in v1.1 and so on.
DanielaValero commentedon Jan 4, 2017
I'd expect the same. So far, did not have time to look deeper into the already available options, but if this is in there, for sure will be part of v1. Otherwise, I'd agree with you by adding this to a v1.1 milestone
evenstensberg commentedon Jan 28, 2017
Fixed #24
nmschulte commentedon Apr 6, 2017
@ev1stensberg, does this apply to hot-module-reloading / webpack-dev-server? I'm looking for a solution to reset Webpack so it'll pick up the new configuration, and have HMR communicate this change appropriately (likely, a "you must manually refresh to pick up latest changes" type message).
How do we enable this in that scenario; is it as simple as watching the files that modify Webpack configuration? How does one use that without causing all watched files to incite a Webpack reset?
evenstensberg commentedon Apr 7, 2017
The resave flag applies to HMR, indeed. Let me get back to you about your issues later this week :)
yacinehmito commentedon May 17, 2017
@ev1stensberg How does #24 solve this issue? It seems like it's not related.
evenstensberg commentedon May 17, 2017
webpack-cli -w -swill refresh everytime you save. I can see that this is actually for the webpack config itself. Insecure if this can be done on the CLI side of things.yacinehmito commentedon May 17, 2017
IMHO we should either reopen this issue or webpack/webpack#3153
evenstensberg commentedon May 17, 2017
Pinging @bebraw for advice
29 remaining items
alexander-akait commentedon Jan 15, 2021
bump
evenstensberg commentedon Apr 24, 2021
https://thisdavej.com/how-to-watch-for-files-changes-in-node-js/ and update the webpack options object, do this at a highest level in the architecture as possible. Should be doable
alexander-akait commentedon Apr 26, 2021
No, it is wrong solution, we need watch any
require/importand nestedrequire/importevenstensberg commentedon Jun 24, 2021
No. We need to watch for when the webpack configuration changes, require/import would be the same
alexander-akait commentedon Jun 24, 2021
@evenstensberg if something was changed in
requireorimportwe should invalidate configuration again, like we do inside webpack for dependenciesalexander-akait commentedon May 3, 2023
Here solution how we can implement this #2797 (comment)
We need:
buildDependeciesfromoptions.cache.buildDependenciesto the top option (it will be useful for any configurations, not only for webpack itself)watchRunhook and get files fromcompilation.modifiedFiles, if we have confiugration file there restart our CLIevenstensberg commentedon Nov 24, 2023
I think it would be easier to in the first iteration to watch for actual configuration file changes, not the compilation itself
binury commentedon Nov 24, 2023
Easier?
evenstensberg commentedon Nov 24, 2023
Yes, implementation wise. We can add cache based invalidation later.
alexander-akait commentedon Dec 26, 2023
We already can implement this if a developer enables cache, we just need
evenstensberg commentedon Jun 26, 2025
This issue should be transfered to /webpack.
alexander-akait commentedon Jun 26, 2025
@evenstensberg It is common problem for webpack-cli and webpack and should be implemented on both sides, so let's keep it here
alexander-akait commentedon Jun 26, 2025
We need to move
buildDependeciesfrom cache to top level option then adding configuration to watch and it will work