Skip to content
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ app.use(webpackMiddleware(webpack({
colors: true
}
// options for formating the statistics

log: console
// Custom logger object
}));
```

Expand Down
11 changes: 6 additions & 5 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ var HASH_REGEXP = /[0-9a-f]{10,}/;
// constructor for the middleware
module.exports = function(compiler, options) {
if(!options) options = {};
var log = options.log || console;
if(typeof options.watchOptions === "undefined") options.watchOptions = {};
if(typeof options.watchDelay !== "undefined") {
// TODO remove this in next major version
console.warn("options.watchDelay is deprecated: Use 'options.watchOptions.aggregateTimeout' instead");
log.warn("options.watchDelay is deprecated: Use 'options.watchOptions.aggregateTimeout' instead");
options.watchOptions.aggregateTimeout = options.watchDelay;
}
if(typeof options.watchOptions.aggregateTimeout === "undefined") options.watchOptions.aggregateTimeout = 200;
Expand Down Expand Up @@ -48,10 +49,10 @@ module.exports = function(compiler, options) {
options.noInfo)
displayStats = false;
if(displayStats) {
console.log(stats.toString(options.stats));
log.log(stats.toString(options.stats));
}
if (!options.noInfo && !options.quiet)
console.info("webpack: bundle is now VALID.");
log.info("webpack: bundle is now VALID.");

// execute callback that are delayed
var cbs = callbacks;
Expand All @@ -71,7 +72,7 @@ module.exports = function(compiler, options) {
// on compiling
function invalidPlugin() {
if(state && (!options.noInfo && !options.quiet))
console.info("webpack: bundle is now INVALID.");
log.info("webpack: bundle is now INVALID.");
// We are now in invalid state
state = false;
}
Expand All @@ -96,7 +97,7 @@ module.exports = function(compiler, options) {
function ready(fn, req) {
if(state) return fn();
if(!options.noInfo && !options.quiet)
console.log("webpack: wait until bundle finished: " + (req.url || fn.name));
log.log("webpack: wait until bundle finished: " + (req.url || fn.name));
callbacks.push(fn);
}

Expand Down