I am running a webpack dev server (v 1.16) like this
let compiler = webpack(webpackConfig);
let webpackServer = new webpackDevServer(compiler);
webpackServer.listen(program.webpackPort);
I want to make changes to the entry points and restart the server. I saw the invalidate method, but the only way I saw this was to call compiler.apply and then server.invalidate () and compiler.apply seem to accept the plugin.
I also saw the close method, but this does not seem to work. If I close it without changing the entry point, it seems to restart correctly. But as soon as I add the first, closing no longer has any effect (and does not display the console). This is how I used the close method.
if(shouldRestart){
webpackConfig.entry = newEntry;
webpackServer.close(); //same reference to server as above
compiler = webpack(webpackConfig);
webpackServer = new webpackDevServer(compiler);
webpackServer.listen(program.webpackPort);
}
, , , . , , .
Server.prototype.close = function(callback) {
this.sockets.forEach(function(sock) {
sock.close();
});
this.listeningApp.close(function() {
this.middleware.close(callback);
}.bind(this));
this.sockets = [];
, close, .
dev webpackConfig, ( , ).