webpack-cli
webpack-cli copied to clipboard
[Feature]: Watch for webpack config changes in watch mode
I'm submitting a feature request
Webpack version: 2.x
Please tell us about your environment: OSX 10.x
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)
Moved from https://github.com/webpack/webpack/issues/3153
@ev1stensberg, @pksjce what you guys think, should this be part of our roadmap to v1 ?
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
Fixed #24
@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?
The resave flag applies to HMR, indeed. Let me get back to you about your issues later this week :)
@ev1stensberg How does #24 solve this issue? It seems like it's not related.
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.
IMHO we should either reopen this issue or https://github.com/webpack/webpack/issues/3153
Pinging @bebraw for advice
It's about restarting the entire process, yeah. Currently you can sort of pull that off with nodemon or similar.
Maybe it's better to re-open this for now.
The current workaround seems to be, as @bebraw suggests, to use nodemon. I'm doing the following which works at the moment:
nodemon --watch webpack.config.js --exec webpack-dev-server --content-base app/
@evenstensberg Is this ticket still valid? Can we close this?
Still valid, we need to lookup webpack config changes too, doing it in the new version
Is this implemented already? 17 days has passed from the last post.... I just got here from the link in the book.
Is this implemented already? 17 days has passed from the last post.... I just got here from the link in the book.
@emilas44 This issue is open since 2016. It is hardly critical. I don't know what you're expecting in 17 days but know that, as most open source projects, webpack is being made by volunteers an is financed by donations. Neither you nor I am entitled to anything but the freedom to contribute to the project.
Moved to #586
@evenstensberg curious why this is moved to #586, aren't they two completely different goals?
The idea of this is that when webpack.config.js saves, webpack reloads and those changes made to the webpack.config.js file take place in the browser without the developer having to go into terminal and do anything.
#586 appears to show that I need to go into the terminal in order to reload webpack. The whole idea here is NOT to go into terminal, but just saving the file automatically reloads everything.
Does this make sense or did I misunderstand?
It looks like you had something working in #24 but that was later removed? What was the reasoning here?
@owenstrevor I'm guessing it was courtesy to avoid flame here. I agree with you though, it's not clear that #586 encompasses the issue addressed here. I'm hopeful it does, but this issue is much much much more focused (and I don't understand why it's not resolved yet, but I appreciate it's getting attention). IMO, this one's a real inconvenience; critical.
The reason we are moving this to this issue is that we're working on a new CLI interface for webpack and a feature there is webpack interactive
which will work as watch mode, but with some additional features. Config changes will be apart of that feature. Would you like me to elaborate some more? Sorry if this came out short-handed, but trying to align the project
@bebraw so has this feature been added to the webpack now?
@lessfish As far as I understand, it didn't happen.
@bebraw sorry to hear that
@bebraw but the issue has been closed, does it mean that the team will not think about this feature?
@lessfish I'm not sure of the current status. I would check webpack 5 release notes. To do this properly, it needs support at the internals.
Sorry, gonna reopen, we're gonna support this.
@evenstensberg any chance we could have a general solution so that modifying content in additional config folders (i.e. node-config
) could also trigger a change?
I think that is a bit out of scope
This issue had no activity for at least half a year.
It's subject to automatic issue closing if there is no activity in the next 15 days.
bump