webpack-dev-server Version: 2.8.2
[ ] This is a feature request
// server.js
const path = require('path')
const webpackDevServer = require('webpack-dev-server')
const webpack = require('webpack')
const config = require('./webpack.config.js')
const options = {
//hot: true,
publicPath: path.resolve(__dirname, '/dist'),
};
webpackDevServer.addDevServerEntrypoints(config, options);
const compiler = webpack(config)
const server = new webpackDevServer(compiler, options);
server.listen(8080, 'localhost', function (err, result) {
if (err) {
return console.log(err);
}
});
HMR available
error in devTools console :
Uncaught SyntaxError: The URL 'http:/sockjs-node' is invalid
at new SockJS (bundle.js:18255)
at socket (bundle.js:16709)
at Object.
at Object.
at __webpack_require__ (bundle.js:678)
at fn (bundle.js:88)
at Object.
at __webpack_require__ (bundle.js:678)
at module.exports.ctor.super_ (bundle.js:724)
at bundle.js:727
Found it : be sure to add options 'port' and 'host' :
`
const options = {
hot: true,
publicPath: path.resolve(__dirname, '/dist'),
port: port,
host: 'localhost',
};
webpackDevServer.addDevServerEntrypoints(config, options);
`
Most helpful comment
Found it : be sure to add options 'port' and 'host' :
`
const options = {
hot: true,
publicPath: path.resolve(__dirname, '/dist'),
port: port,
host: 'localhost',
};
webpackDevServer.addDevServerEntrypoints(config, options);
`