Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bebraw opened this issue Dec 24, 2016 · 39 comments
Open

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

bebraw opened this issue Dec 24, 2016 · 39 comments

Comments

@bebraw
Copy link

bebraw commented Dec 24, 2016

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 webpack/webpack#3153

@DanielaValero DanielaValero changed the title Watch for webpack config changes in watch mode Feature: Watch for webpack config changes in watch mode Jan 3, 2017
@DanielaValero
Copy link
Contributor

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

@bebraw
Copy link
Author

bebraw commented 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
Copy link
Contributor

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
Copy link
Member

evenstensberg commented Jan 28, 2017

Fixed #24

@nmschulte
Copy link

@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
Copy link
Member

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

@yacinehmito
Copy link

yacinehmito commented May 17, 2017

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

@evenstensberg
Copy link
Member

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.

@yacinehmito
Copy link

IMHO we should either reopen this issue or webpack/webpack#3153

@evenstensberg
Copy link
Member

Pinging @bebraw for advice

@bebraw
Copy link
Author

bebraw commented May 17, 2017

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 bebraw reopened this May 17, 2017
@scarlac
Copy link

scarlac commented Sep 9, 2017

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/

ulivz added a commit to vuejs/vuepress that referenced this issue Jul 25, 2018
It's reported by #664, but #664 cannot be fixed fully since watching webpack config changes shouldn't be handled in VuePresss

VuePress can only ensure that when user changes the markdown config, the cache identifier will be updated, so user needn't to clean the ./node_modules/.cache muanully.

See: webpack/webpack#3153, webpack/webpack-cli#15
ulivz added a commit to vuejs/vuepress that referenced this issue Jul 25, 2018
It's reported by #664, but #664 cannot be fixed fully since watching webpack config changes shouldn't be handled in VuePresss

VuePress can only ensure that when user changes the markdown config, the cache identifier will be updated, so user needn't to clean the ./node_modules/.cache manually.

See: webpack/webpack#3153, webpack/webpack-cli#15
@sendilkumarn
Copy link
Member

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

@evenstensberg
Copy link
Member

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

@emilas44
Copy link

emilas44 commented Dec 21, 2018

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

@yacinehmito
Copy link

yacinehmito commented Dec 21, 2018

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.

@lessfish
Copy link

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

@bebraw
Copy link
Author

bebraw commented Oct 17, 2019

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

@lessfish
Copy link

@bebraw sorry to hear that

@lessfish
Copy link

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

@bebraw
Copy link
Author

bebraw commented Oct 17, 2019

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

@evenstensberg
Copy link
Member

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

@soulofmischief
Copy link

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

@evenstensberg
Copy link
Member

I think that is a bit out of scope

@evenstensberg evenstensberg changed the title Feature: Watch for webpack config changes in watch mode [Feature]: Watch for webpack config changes in watch mode Oct 31, 2019
devs-cloud pushed a commit to devs-cloud/vue-dev that referenced this issue Dec 27, 2019
It's reported by #664, but #664 cannot be fixed fully since watching webpack config changes shouldn't be handled in VuePresss

VuePress can only ensure that when user changes the markdown config, the cache identifier will be updated, so user needn't to clean the ./node_modules/.cache manually.

See: webpack/webpack#3153, webpack/webpack-cli#15
@webpack-bot
Copy link

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.

@alexander-akait
Copy link
Member

bump

@evenstensberg
Copy link
Member

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
Copy link
Member

No, it is wrong solution, we need watch any require/import and nested require/import

@evenstensberg
Copy link
Member

No. We need to watch for when the webpack configuration changes, require/import would be the same

@alexander-akait
Copy link
Member

@evenstensberg if something was changed in require or import we should invalidate configuration again, like we do inside webpack for dependencies

@alexander-akait
Copy link
Member

alexander-akait commented May 3, 2023

Here solution how we can implement this #2797 (comment)

We need:

  • move buildDependecies from options.cache.buildDependencies to the top option (it will be useful for any configurations, not only for webpack itself)
  • implement watchRun hook and get files from compilation.modifiedFiles, if we have confiugration file there restart our CLI

@evenstensberg
Copy link
Member

I think it would be easier to in the first iteration to watch for actual configuration file changes, not the compilation itself

@binury
Copy link

binury commented 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

Easier?

@evenstensberg
Copy link
Member

Yes, implementation wise. We can add cache based invalidation later.

@alexander-akait
Copy link
Member

We already can implement this if a developer enables cache, we just need

implement watchRun hook and get files from compilation.modifiedFiles, if we have confiugration file there restart our CLI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.