webpack-dev-server: Running the server does not compile files or reload page in windows.
From the docs it says:
It binds a small express server on localhost:8080 which serves your static assets as well as the bundle (compiled automatically). It automatically updates the browser page when a bundle is recompiled (socket.io). Open http://localhost:8080/webpack-dev-server/bundle in your browser.
However if I run it this doesn’t happen: I just get the following, but when I go to the serving URL I still have my old code.
C:\Users\Laptop\WebstormProjects\wirejs-client>npm run start
> wirejs-client@0.1.0 start C:\Users\Laptop\WebstormProjects\wirejs-client
> webpack-dev-server
http://localhost:8080/webpack-dev-server/
webpack result is served from /
content is served from C:\Users\Laptop\WebstormProjects\wirejs-client
webpack: wait until bundle finished: /webpack-dev-server/
Hash: 25bf81a3ab16cfec1760
Version: webpack 1.8.4
Time: 8688ms
Asset Size Chunks Chunk Names
bundle.js 4.37 kB 0 [emitted] main
bundle.js.map 4 kB 0 [emitted] main
chunk {0} bundle.js, bundle.js.map (main) 2.69 kB [rendered]
[0] ./app/main.js 295 bytes {0} [built]
[1] ./app/wirejs-client.js 2.39 kB {0} [built]
webpack: bundle is now VALID.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 73 (4 by maintainers)
Links to this issue
Commits related to this issue
- Fixed issue where hot reloading doesn't work on Linux. Ref: https://github.com/webpack/webpack-dev-server/issues/155 — committed to ChavdarSlavov/training-build-base by deleted user 8 years ago
Maybe webpack-dev-server compiles your code, but did not know when to send them to the browser. Also, webpack-dev-server stores the compiled bundle in memory, thus the old copy remains in the file system. That’s why your browser are always getting the old files.
Webpack-dev-server reads
output.publicPathin the config. Whenever browser sends a request to get file under that path, it tries to return the compiled bundle.If you access your
bundle.jsusing<script src="/build/bundle.js"></script>, you may try the following in the CLI, which should be equivalent to setting upoutput.publicPathin a config file:I have found the solution for this on Vagrant shared folders:
Now my bundle will properly get rebuilt.
I had a similar problem on Windows.
webpack-dev-serverin one of the projects just wouldn’t react to changes to .js files. In the end the reason was quite stupid: you just can’t use certain symbols in a path to the project. For example, if there are braces there ((),[]), the changes won’t be seen by webpack-dev-server; with an!it won’t even start. Maybe there are more, just didn’t bother digging.Hope someone finds this helpful.
you need to access it from http://host:port/webpack-dev-server/ and not from http://host:port/ to get it reloading the browser that or add --inline --hot
The closest I can get to what I want, is to run these in separate terminals
webpack --watch webpack-dev-server
Just followed the getting started tutorial. Webpack dev server does not reload the browser after recompiling. I’m on Win 10
It seems a common pattern with any node project. Things break apart even before finishing introduction.
Edit: Here’s what works for me:
webpack-dev-server --progress --inlineif you only care about browser reload and don’t need to set up hot mode than follow this workaround:
That’s it. Now your browser should reload every time you modify something in your code. Hopefully this helps.
Depending on what editor you’re using, that could be causing the issue. Just found out that WebStorm was giving me this problem from Windows but not on Ubuntu (the settings must have been different on each).
The setting I had to disable which made all the difference was
use "safe write"(found in Appearance & Behaviour > System Settings), which saves changes first to a temporary file. Saving like that doesn’t get picked up by webpack of course, was the cause of much frustration.Also experienced this problem with
webpack-hot-middlewareon my own express-server.Adding
watchOptionsto mywebpack-dev-middleware-options solved this for me.relevant part of my server.js:
Windows 10 - IntelliJ Ultimate (aka Webstrom) this solved it for me:
<< Depending on what editor you’re using, that could be causing the issue. Just found out that WebStorm was giving me this problem from Windows but not on Ubuntu (the settings must have been different on each).
The setting I had to disable which made all the difference was use “safe write” (found in Appearance & Behaviour > System Settings), which saves changes first to a temporary file. Saving like that doesn’t get picked up by webpack of course, was the cause of much frustration. >> Thanks to @lostpebble
Having the same problem due to Dropbox using
()in its naming convention for Dropbox for Business accounts:~/Dropbox (business name)/. Tried symlinking but webpack ignores the symlink and uses the original path.While vbox shared folders update content they do not update the mtime of the file. If I touch the file on the guest machine it then reloads. I’m assuming inotify (or equivalent doesn’t pick up these changes). More active scanning or a vbox fix seem like the only route.
Closing because there are several answers to the problem. Some of these issues are also documented.
If anyone still has an issue, feel free to create a new issue.
@Kekesed I managed to get it working it appears that it was caused by the paths not being correct for Windows. Wrap any applicable paths in
path.resolveandpath.joinshould do the job.Here’s the updated config feel free to clone my repo and test for yourselves.
Moved from OS X to Windows 10 and now
webpack-dev-serveris not detecting changes and rebuilding the bundle. I’m using Atom so there’s no safe write, so that shouldn’t be the problem.I’ve attempted most solutions in this issue to no avail.
Here’s my config see
devServer.change lazy option off
it works me win7 well!
my config :
Well this is a popular issue.
I’m having the same issue. For now I’m running webpack-dev-server inside Vagrant.
UPDATE: not working on Vagrant, probably because it’s a shared folder :{
@QuantumInformation If you want it to live reload, you’ll need to setup hot mode as instructed here: http://webpack.github.io/docs/webpack-dev-server.html#hot-mode