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

Restart after config change #440

Closed
jzaefferer opened this issue Mar 31, 2016 · 5 comments
Closed

Restart after config change #440

jzaefferer opened this issue Mar 31, 2016 · 5 comments

Comments

@jzaefferer
Copy link

This is a minor feature request: In addition to regular source files, also watch for changes on the webpack.config.js file. When it changes, restart the entire process (or whatever subprocess/system necessary) to run with the updated config.

Helps avoid the issue of config changes not applying to the running server, which sometimes takes minutes to hours to realize.

If this sounds like a good idea, I may be able to help implement it (haven't yet looked at the source of this repo).

@gartz
Copy link

gartz commented Mar 31, 2016

Or allow, add list of files to watch for changes that restart the server if changed.

@diskodan
Copy link

diskodan commented Apr 5, 2016

I found a way to do this with the ever-useful nodemon
nodemon restarts webpack-dev-server any time I change my webpack.config.js file.


I frequently forget to restart my server after config changes and I've wasted lots of time "debugging" things that work because of that. I think anything that can lower the cognitive overhead in our workflows is generally worthwhile. The fewer environmental gotchas I need to worry about, the more of my limited brainpower I can direct towards the important stuff--writing cool apps.

However I can see an argument for not adding a restart feature to webpack (keeping it light and focused on what it does well). If my 'nodemon' hack is sufficient, perhaps it could become an example in the documentation.


I've set up the command in my packages.json as the start script .
  I now run $ npm start
  instead of $ webpack-dev-server

"scripts": {
  "start": "nodemon --watch webpack.config.js ./node_modules/.bin/webpack-dev-server",

  "test": "echo \"Error: no test specified. Write some tests, you slacker\" && exit 1"
},
"dependencies": 
  ...

note: nodemon's --watch flag doesn't like paths to be prefixed with ./

@SpaceK33z
Copy link
Member

I've been thinking about this for a bit, and I think this is actually something that should be fixed in webpack. webpack already has watchpack as a dependency (a package to watch files), and has the power to reload the config. It wouldn't make sense to do this in the dev-server, since it doesn't know anything about the config itself.

@SpaceK33z
Copy link
Member

See webpack/webpack#3153.

@shettayyy
Copy link

shettayyy commented Jul 31, 2018

@diskodan For some reason, nodemon --watch config/webpack.config.js --exec webpack-dev-server --config config/webpack.config.js doesn't work. More details: https://stackoverflow.com/questions/51611788/nodemon-failed-to-parse-config-webpack-config-js

EDIT: I figured it out

"start:dev": "nodemon --watch config --exec 'webpack-dev-server --config ./config/webpack.config.js'"

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

No branches or pull requests

5 participants