Skip to content

Commit dfd4826

Browse files
committed
fix(Server): cascade stats options
1 parent f78a9a3 commit dfd4826

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

lib/Server.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ if (semver.satisfies(process.version, '8.6.0 - 9')) {
7272
tls.DEFAULT_ECDH_CURVE = 'auto';
7373
}
7474

75-
const STATS = {
76-
all: false,
77-
hash: true,
78-
assets: true,
79-
warnings: true,
80-
errors: true,
81-
errorDetails: false,
82-
};
83-
8475
class Server {
8576
constructor(compiler, options = {}, _log) {
8677
this.log = _log || createLogger(options);
@@ -91,6 +82,15 @@ class Server {
9182
throw new Error("'filename' option must be set in lazy mode.");
9283
}
9384

85+
this.stats = options.stats;
86+
this.DEFAULT_STATS = {
87+
all: false,
88+
hash: true,
89+
assets: true,
90+
warnings: true,
91+
errors: true,
92+
errorDetails: false,
93+
};
9494
this.hot = options.hot || options.hotOnly;
9595
this.headers = options.headers;
9696
this.progress = options.progress;
@@ -144,7 +144,7 @@ class Server {
144144
compile.tap('webpack-dev-server', invalidPlugin);
145145
invalid.tap('webpack-dev-server', invalidPlugin);
146146
done.tap('webpack-dev-server', (stats) => {
147-
this._sendStats(this.sockets, stats.toJson(STATS));
147+
this._sendStats(this.sockets, this.getStats(stats));
148148
this._stats = stats;
149149
});
150150
};
@@ -650,6 +650,13 @@ class Server {
650650
}, this);
651651
}
652652

653+
getStats(statsObj) {
654+
return Object.assign(
655+
statsObj.toJson(this.DEFAULT_STATS),
656+
statsObj.toJson(this.stats)
657+
);
658+
}
659+
653660
use() {
654661
// eslint-disable-next-line
655662
this.app.use.apply(this.app, arguments);
@@ -817,7 +824,7 @@ class Server {
817824
return;
818825
}
819826

820-
this._sendStats([connection], this._stats.toJson(STATS), true);
827+
this._sendStats([connection], this.getStats(this._stats), true);
821828
});
822829

823830
socket.installHandlers(this.listeningApp, {

0 commit comments

Comments
 (0)