Skip to content

Commit 6144c8d

Browse files
fix: warnings in overlay (#3054)
1 parent c773d1f commit 6144c8d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

client-src/default/index.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,48 @@ self.addEventListener('beforeunload', () => {
3030

3131
if (typeof window !== 'undefined') {
3232
const qs = window.location.search.toLowerCase();
33+
3334
options.hotReload = qs.indexOf('hotreload=false') === -1;
3435
}
3536

3637
const onSocketMessage = {
3738
hot() {
3839
options.hot = true;
40+
3941
log.info('Hot Module Replacement enabled.');
4042
},
4143
liveReload() {
4244
options.liveReload = true;
45+
4346
log.info('Live Reloading enabled.');
4447
},
4548
invalid() {
4649
log.info('App updated. Recompiling...');
50+
4751
// fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
4852
if (options.useWarningOverlay || options.useErrorOverlay) {
4953
overlay.clear();
5054
}
55+
5156
sendMessage('Invalid');
5257
},
5358
hash(hash) {
5459
status.currentHash = hash;
5560
},
5661
'still-ok': function stillOk() {
5762
log.info('Nothing changed.');
63+
5864
if (options.useWarningOverlay || options.useErrorOverlay) {
5965
overlay.clear();
6066
}
67+
6168
sendMessage('StillOk');
6269
},
6370
logging: function logging(level) {
6471
// this is needed because the HMR logger operate separately from
6572
// dev server logger
6673
const hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
74+
6775
if (hotCtx.keys().indexOf('./log') !== -1) {
6876
hotCtx('./log').setLogLevel(level);
6977
}
@@ -90,29 +98,40 @@ const onSocketMessage = {
9098
if (options.useProgress) {
9199
log.info(`${data.percent}% - ${data.msg}.`);
92100
}
101+
93102
sendMessage('Progress', data);
94103
},
95104
ok() {
96105
sendMessage('Ok');
106+
97107
if (options.useWarningOverlay || options.useErrorOverlay) {
98108
overlay.clear();
99109
}
110+
100111
if (options.initial) {
101112
return (options.initial = false);
102113
}
114+
103115
reloadApp(options, status);
104116
},
105117
'content-changed': function contentChanged() {
106118
log.info('Content base changed. Reloading...');
119+
107120
self.location.reload();
108121
},
109122
warnings(warnings) {
110123
log.warn('Warnings while compiling.');
111-
const strippedWarnings = warnings.map((warning) => stripAnsi(warning));
124+
125+
const strippedWarnings = warnings.map((warning) =>
126+
stripAnsi(warning.message ? warning.message : warning)
127+
);
128+
112129
sendMessage('Warnings', strippedWarnings);
130+
113131
for (let i = 0; i < strippedWarnings.length; i++) {
114132
log.warn(strippedWarnings[i]);
115133
}
134+
116135
if (options.useWarningOverlay) {
117136
overlay.showMessage(warnings);
118137
}
@@ -125,16 +144,21 @@ const onSocketMessage = {
125144
},
126145
errors(errors) {
127146
log.error('Errors while compiling. Reload prevented.');
147+
128148
const strippedErrors = errors.map((error) =>
129149
stripAnsi(error.message ? error.message : error)
130150
);
151+
131152
sendMessage('Errors', strippedErrors);
153+
132154
for (let i = 0; i < strippedErrors.length; i++) {
133155
log.error(strippedErrors[i]);
134156
}
157+
135158
if (options.useErrorOverlay) {
136159
overlay.showMessage(errors);
137160
}
161+
138162
options.initial = false;
139163
},
140164
error(error) {

lib/Server.js

+1
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ class Server {
746746

747747
const configArr = getCompilerConfigArray(this.compiler);
748748
const statsOption = getStatsOption(configArr);
749+
749750
if (typeof statsOption === 'object' && statsOption.warningsFilter) {
750751
stats.warningsFilter = statsOption.warningsFilter;
751752
}

0 commit comments

Comments
 (0)