Skip to content

feat(onUpdate): accept a callback as options.onUpdate #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ app.use(webpackMiddleware(webpack({
// switch into lazy mode
// that means no watching, but recompilation on every request

onUpdate: function(stats) { doWhateverWithStats(stats); },
// manually handle the stats from the last compilation
// can be combined with quiet and noInfo for full control over output

watchOptions: {
aggregateTimeout: 300,
poll: true
Expand Down
4 changes: 4 additions & 0 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module.exports = function(compiler, options) {
process.nextTick(function() {
// check if still in valid state
if(!state) return;

// make a callback with stats
if(typeof options.onUpdate === 'function') options.onUpdate(stats);

// print webpack output
var displayStats = (!options.quiet && options.stats !== false);
if(displayStats &&
Expand Down