I'm trying to add a callback to the webpack-dev-server module in Gulp. The callback has as a goal to notify users the URL where the dev server is started. The issue is that the callback is invoked before the bundling process finishes.
If I add a fixed timeout that works, but this is clearly undesired.
Question: Am I doing something wrong with the callback structure? Why is that being called before the bundle is finished?
My code in Gulp:
var server = new WebpackDevServer(webpack(devWebpackConfig), devServerConfig);
server.listen(options.devServerPort || 8080, 'localhost', function(err) {
if(err) {
console.error('[webpack-dev-server] failed to start:', err);
} else {
console.log('[webpack-dev-server] started:', 'Browse to http://localhost:'+ options.devServerPort +'/webpack-dev-server/');
}
});
Current output:
[14:43:43] Finished 'dev' after 66 ms
[webpack-dev-server] started: Browse to http://localhost:8002/webpack-dev-server/
Hash: 638bdaa3201a4220c58e
Version: webpack 1.9.5
Time: 7315ms
Asset Size Chunks Chunk Names
c91905265455192ab6ea13d95c9edc63.woff 42.6 kB [emitted]
b09bad3c727751c808f224df00c208f8.woff 99.6 kB [emitted]
index.js 4.83 MB 0, 1 [emitted] styles, app
chunk {0} index.js (styles) 117 kB [rendered]
.....
webpack: bundle is now VALID.
What I'm expecting:
[14:43:43] Finished 'dev' after 66 ms
Hash: 638bdaa3201a4220c58e
Version: webpack 1.9.5
Time: 7315ms
Asset Size Chunks Chunk Names
c91905265455192ab6ea13d95c9edc63.woff 42.6 kB [emitted]
b09bad3c727751c808f224df00c208f8.woff 99.6 kB [emitted]
index.js 4.83 MB 0, 1 [emitted] styles, app
chunk {0} index.js (styles) 117 kB [rendered]
...
webpack: bundle is now VALID.
[webpack-dev-server] started: Browse to http://localhost:8002/webpack-dev-server/
Alan