Skip to content

Commit

Permalink
fix(Server): cascade stats options
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannmoinet committed Feb 14, 2019
1 parent f78a9a3 commit dfd4826
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ if (semver.satisfies(process.version, '8.6.0 - 9')) {
tls.DEFAULT_ECDH_CURVE = 'auto';
}

const STATS = {
all: false,
hash: true,
assets: true,
warnings: true,
errors: true,
errorDetails: false,
};

class Server {
constructor(compiler, options = {}, _log) {
this.log = _log || createLogger(options);
Expand All @@ -91,6 +82,15 @@ class Server {
throw new Error("'filename' option must be set in lazy mode.");
}

this.stats = options.stats;
this.DEFAULT_STATS = {
all: false,
hash: true,
assets: true,
warnings: true,
errors: true,
errorDetails: false,
};
this.hot = options.hot || options.hotOnly;
this.headers = options.headers;
this.progress = options.progress;
Expand Down Expand Up @@ -144,7 +144,7 @@ class Server {
compile.tap('webpack-dev-server', invalidPlugin);
invalid.tap('webpack-dev-server', invalidPlugin);
done.tap('webpack-dev-server', (stats) => {
this._sendStats(this.sockets, stats.toJson(STATS));
this._sendStats(this.sockets, this.getStats(stats));
this._stats = stats;
});
};
Expand Down Expand Up @@ -650,6 +650,13 @@ class Server {
}, this);
}

getStats(statsObj) {
return Object.assign(
statsObj.toJson(this.DEFAULT_STATS),
statsObj.toJson(this.stats)
);
}

use() {
// eslint-disable-next-line
this.app.use.apply(this.app, arguments);
Expand Down Expand Up @@ -817,7 +824,7 @@ class Server {
return;
}

this._sendStats([connection], this._stats.toJson(STATS), true);
this._sendStats([connection], this.getStats(this._stats), true);
});

socket.installHandlers(this.listeningApp, {
Expand Down

0 comments on commit dfd4826

Please sign in to comment.