@@ -11,6 +11,17 @@ const srcByModuleId = Object.create(null);
11
11
12
12
const noDocument = typeof document === "undefined" ;
13
13
14
+ const logLevels = {
15
+ none : 6 ,
16
+ false : 6 ,
17
+ error : 5 ,
18
+ warn : 4 ,
19
+ info : 3 ,
20
+ log : 2 ,
21
+ true : 2 ,
22
+ verbose : 1 ,
23
+ } ;
24
+
14
25
const { forEach } = Array . prototype ;
15
26
16
27
function debounce ( fn , time ) {
@@ -207,8 +218,12 @@ function isUrlRequest(url) {
207
218
}
208
219
209
220
module . exports = function ( moduleId , options ) {
221
+ const logLevel = logLevels [ options . logLevel ] || logLevels . info ;
222
+
210
223
if ( noDocument ) {
211
- console . log ( "no window.document found, will not HMR CSS" ) ;
224
+ if ( logLevel <= logLevels . warn ) {
225
+ console . warn ( "no window.document found, will not HMR CSS" ) ;
226
+ }
212
227
213
228
return noop ;
214
229
}
@@ -220,17 +235,23 @@ module.exports = function (moduleId, options) {
220
235
const reloaded = reloadStyle ( src ) ;
221
236
222
237
if ( options . locals ) {
223
- console . log ( "[HMR] Detected local css modules. Reload all css" ) ;
238
+ if ( logLevel <= logLevels . info ) {
239
+ console . log ( "[HMR] Detected local css modules. Reload all css" ) ;
240
+ }
224
241
225
242
reloadAll ( ) ;
226
243
227
244
return ;
228
245
}
229
246
230
247
if ( reloaded ) {
231
- console . log ( "[HMR] css reload %s" , src . join ( " " ) ) ;
248
+ if ( logLevel <= logLevels . info ) {
249
+ console . log ( "[HMR] css reload %s" , src . join ( " " ) ) ;
250
+ }
232
251
} else {
233
- console . log ( "[HMR] Reload all css" ) ;
252
+ if ( logLevel <= logLevels . info ) {
253
+ console . log ( "[HMR] Reload all css" ) ;
254
+ }
234
255
235
256
reloadAll ( ) ;
236
257
}
0 commit comments