I'm trying to set up the webpack-dev-server to watch for changes using the polling mechanism. Polling in general works if I do webpack --watch --watch-polling as mentioned in https://github.com/webpack/webpack/issues/125#issuecomment-109582926, however I cannot get it to work in webpack-dev-server. Following the docs, I'm trying to pass the following option:
watchOptions: {
poll: true
}
I can confirm that this is an issue with the release (v1.9.0) and commit 8e8f540. Appears to be an issue with socket.io as the exception is on line 23 of socket.io/lib/transport/polling.js
https://github.com/Automattic/engine.io-client/blob/d0e8643d050196ce29d88438d129230817f89c85/lib/transports/polling.js
The webpack output is as follows, and causes an exception (object is not a function):
var xhr = new XMLHttpRequest({ xdomain: false });
Executing the following on the console works as expected:
var xhr = new XMLHttpRequest.XMLHttpRequest({ xdomain: false });
Comparing the result of var XMLHttpRequest = webpack_require(/*! xmlhttprequest */ 19);
Not working:
function XMLHttpRequest()
Working:
function module.exports(opts)
Checking my make-webpack-config.js, I found the problem:
var externals = [{
xmlhttprequest: '{XMLHttpRequest:XMLHttpRequest}'
}];
Removing xmlhttprequest from this array solved my problem. I am pretty sure I put it in there to resolve this issue: https://github.com/webpack/webpack-dev-server/issues/66
@sokra Keep up the great work!
@maspwr as written here http://webpack.github.io/docs/webpack-dev-server.html
you must put these lines:
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
into WebpackDevServer constructor.
This works fine for me.
@Andrew8xx8 works like a charme with my vagrant setup. Thank you.
I see that others aren't having this issue. I'll retest when I need to use that functionality again and reopen if I can reproduce the issue. Thanks.
Most helpful comment
@maspwr as written here http://webpack.github.io/docs/webpack-dev-server.html
you must put these lines:
into WebpackDevServer constructor.
This works fine for me.