webpack-cli icon indicating copy to clipboard operation
webpack-cli copied to clipboard

[Feature]: Watch for webpack config changes in watch mode

Open bebraw opened this issue 7 years ago • 39 comments

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

bebraw avatar Dec 24 '16 07:12 bebraw

@ev1stensberg, @pksjce what you guys think, should this be part of our roadmap to v1 ?

DanielaValero avatar Jan 04 '17 09:01 DanielaValero

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.

bebraw avatar Jan 04 '17 09:01 bebraw

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

DanielaValero avatar Jan 04 '17 11:01 DanielaValero

Fixed #24

evenstensberg avatar Jan 28 '17 13:01 evenstensberg

@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?

nmschulte avatar Apr 06 '17 22:04 nmschulte

The resave flag applies to HMR, indeed. Let me get back to you about your issues later this week :)

evenstensberg avatar Apr 07 '17 09:04 evenstensberg

@ev1stensberg How does #24 solve this issue? It seems like it's not related.

yacinehmito avatar May 17 '17 16:05 yacinehmito

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.

evenstensberg avatar May 17 '17 17:05 evenstensberg

IMHO we should either reopen this issue or https://github.com/webpack/webpack/issues/3153

yacinehmito avatar May 17 '17 17:05 yacinehmito

Pinging @bebraw for advice

evenstensberg avatar May 17 '17 17:05 evenstensberg

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.

bebraw avatar May 17 '17 17:05 bebraw

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/

scarlac avatar Sep 09 '17 13:09 scarlac

@evenstensberg Is this ticket still valid? Can we close this?

sendilkumarn avatar Dec 03 '18 20:12 sendilkumarn

Still valid, we need to lookup webpack config changes too, doing it in the new version

evenstensberg avatar Dec 04 '18 09:12 evenstensberg

Is this implemented already? 17 days has passed from the last post.... I just got here from the link in the book.

emilas44 avatar Dec 21 '18 19:12 emilas44

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.

yacinehmito avatar Dec 21 '18 20:12 yacinehmito

Moved to #586

evenstensberg avatar Feb 05 '19 14:02 evenstensberg

@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 avatar Feb 26 '19 18:02 owenstrevor

@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.

nmschulte avatar Feb 26 '19 20:02 nmschulte

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

evenstensberg avatar Mar 03 '19 22:03 evenstensberg

@bebraw so has this feature been added to the webpack now?

lessfish avatar Oct 17 '19 08:10 lessfish

@lessfish As far as I understand, it didn't happen.

bebraw avatar Oct 17 '19 08:10 bebraw

@bebraw sorry to hear that

lessfish avatar Oct 17 '19 08:10 lessfish

@bebraw but the issue has been closed, does it mean that the team will not think about this feature?

lessfish avatar Oct 17 '19 08:10 lessfish

@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.

bebraw avatar Oct 17 '19 08:10 bebraw

Sorry, gonna reopen, we're gonna support this.

evenstensberg avatar Oct 19 '19 12:10 evenstensberg

@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?

soulofmischief avatar Oct 27 '19 20:10 soulofmischief

I think that is a bit out of scope

evenstensberg avatar Oct 29 '19 16:10 evenstensberg

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.

webpack-bot avatar Jan 15 '21 15:01 webpack-bot

bump

alexander-akait avatar Jan 15 '21 15:01 alexander-akait