Skip to content

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

Open

Description

@bebraw

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

Activity

  1. changed the title [-]Watch for webpack config changes in watch mode[/-] [+]Feature: Watch for webpack config changes in watch mode[/+] on Jan 3, 2017
  2. DanielaValero commented on Jan 4, 2017

    @DanielaValero
    Contributor

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

  3. bebraw commented on Jan 4, 2017

    @bebraw
    Author

    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.

  4. DanielaValero commented on Jan 4, 2017

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

  5. evenstensberg commented on Jan 28, 2017

    @evenstensberg
    Member

    Fixed #24

  6. nmschulte commented on Apr 6, 2017

    @nmschulte

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

  7. evenstensberg commented on Apr 7, 2017

    @evenstensberg
    Member

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

  8. yacinehmito commented on May 17, 2017

    @yacinehmito

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

  9. evenstensberg commented on May 17, 2017

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

  10. yacinehmito commented on May 17, 2017

    @yacinehmito

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

  11. evenstensberg commented on May 17, 2017

    @evenstensberg
    Member

    Pinging @bebraw for advice

  12. 29 remaining items

  13. alexander-akait commented on Jan 15, 2021

    @alexander-akait
    Member

    bump

  14. evenstensberg commented on Apr 24, 2021

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

  15. alexander-akait commented on Apr 26, 2021

    @alexander-akait
    Member

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

  16. evenstensberg commented on Jun 24, 2021

    @evenstensberg
    Member

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

  17. alexander-akait commented on Jun 24, 2021

    @alexander-akait
    Member

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

  18. alexander-akait commented on May 3, 2023

    @alexander-akait
    Member

    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
  19. evenstensberg commented on Nov 24, 2023

    @evenstensberg
    Member

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

  20. binury commented on Nov 24, 2023

    @binury

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

    Easier?

  21. evenstensberg commented on Nov 24, 2023

    @evenstensberg
    Member

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

  22. alexander-akait commented on Dec 26, 2023

    @alexander-akait
    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

  23. evenstensberg commented on Jun 26, 2025

    @evenstensberg
    Member

    This issue should be transfered to /webpack.

  24. alexander-akait commented on Jun 26, 2025

    @alexander-akait
    Member

    @evenstensberg It is common problem for webpack-cli and webpack and should be implemented on both sides, so let's keep it here

  25. alexander-akait commented on Jun 26, 2025

    @alexander-akait
    Member

    We need to move buildDependecies from cache to top level option then adding configuration to watch and it will work

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions