Webpack-dev-server: No way to have a callback after build completes

Created on 14 Mar 2015  路  4Comments  路  Source: webpack/webpack-dev-server

I expected the callback when running listen to happen after the build was complete, but instead it calls right after. Any recommendation for having a hook that runs after the build?

I'd like to output stats on how long it took to build in the console.

Most helpful comment

var compiler = webpack(...);
compiler.plugin("done", function() { ... });
new WebpackDevServer(compiler, ...

All 4 comments

var compiler = webpack(...);
compiler.plugin("done", function() { ... });
new WebpackDevServer(compiler, ...

Nice, thank you. I tried this, but now it does this:

build took 12154ms
Your build is complete.
Note: If you see a warning about your routes, this is ok!
We do dynamic requires that causes Webpack to output this error
Hash: 8e732e1dd38dc1252ce6
Version: webpack 1.7.0
Time: 12088ms
       Asset     Size  Chunks             Chunk Names
 sunrise.jpg    61778          [emitted]  
   river.jpg    35232          [emitted]  
  winter.jpg    30584          [emitted]  
yosemite.jpg    93280          [emitted]  
     main.js  1703306       0  [emitted]  main
chunk    {0} main.js (main) 1508450 [rendered]
...

I guess I can do a setTimeout, but is there a cleaner way to hook in so I can output that stuff _after_ the build stats?

The setTimeout seems to work alright for now.

@sokra ,Thanks for your pretty answer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daryn-k picture daryn-k  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

hnqlvs picture hnqlvs  路  3Comments

Jack-Works picture Jack-Works  路  3Comments

mischkl picture mischkl  路  3Comments