Skip to content

Commit 309f252

Browse files
committed
feat(onUpdate): accept a callback as options.onUpdate
If options.onUpdate is provided, it will be called with the stats results of the compilation on every build. In combination with setting options.quiet, it allows the user to manually handle the logging of the stats.
1 parent a9fc7f4 commit 309f252

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ app.use(webpackMiddleware(webpack({
4747
// switch into lazy mode
4848
// that means no watching, but recompilation on every request
4949

50+
onUpdate: function(stats) { doWhateverWithStats(stats); },
51+
// manually handle the stats from the last compilation
52+
// can be combined with quiet and noInfo for full control over output
53+
5054
watchOptions: {
5155
aggregateTimeout: 300,
5256
poll: true

middleware.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ module.exports = function(compiler, options) {
4040
process.nextTick(function() {
4141
// check if still in valid state
4242
if(!state) return;
43+
44+
// make a callback with stats
45+
if(typeof options.onUpdate === 'function') options.onUpdate(stats);
46+
4347
// print webpack output
4448
var displayStats = (!options.quiet && options.stats !== false);
4549
if(displayStats &&

0 commit comments

Comments
 (0)