Do you want to request a feature or report a bug?
I am not sure whether this is by design (in which case I want to request a change), or a bug.
What is the current behavior?
The callback for listen is called immediately after the server is reachable on the specified port.
If the current behavior is a bug, please provide the steps to reproduce.
const webpack = require('webpack');
const config = require('../webpack.config.server');
const WebpackDevServer = require('webpack-dev-server');
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, config.devServer);
server.listen(config.devServer.port, () => {
});
What is the expected behavior?
I expected the callback to be called after compilation had finished (and all javascript bundles were created). This is because my callback is a testing suite which needs the server online (currently the callback satisfies this), but also needs the files to be already-created.
If this is a feature request, what is motivation or use case for changing the behavior?
I want to request the option to be able to run a function after the initial compiling finishes, so that I can run my test suites.
Please mention your webpack and Operating System version.
webpack ^2, webpack-dev-server ^2, ubuntu 14.04
A callback that fires when compilation is finished is available as compiler.plugin('done', cb).
I happen to have made a test suite runner like you have too, this is some code out of mine:
compiler.plugin('done', (stats) => {
stats = stats.toJson();
if (stats.errors && stats.errors.length > 0) {
// show errors
return;
}
// compilation success
});
The .listen callback is by design, there are many cases where you immediately want to do something after the server has started, like show the URL.
Ha, well I'll be damned.
is there a way to catch this error...
```events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL 10.211.55.5:3000
```
happens when the host domain doesnt exist on the machine, i want to log an error telling the devs to add a hostfile entry.
Most helpful comment
A callback that fires when compilation is finished is available as
compiler.plugin('done', cb).I happen to have made a test suite runner like you have too, this is some code out of mine:
The
.listencallback is by design, there are many cases where you immediately want to do something after the server has started, like show the URL.