Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ module.exports = {
};
```

### `stats`

Type: `String|Boolean`
Default: `'normal'`

The [logging preset](https://webpack.js.org/configuration/stats/#stats-presets) to use. Object syntax is unsupported at this time.

## Examples

### Minimal example
Expand Down
19 changes: 15 additions & 4 deletions src/hmr/hotModuleReplacement.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,19 @@ function isUrlRequest(url) {
}

module.exports = function(moduleId, options) {
// By default, log everything. For certain presets, do not log informational
// messages. See https://webpack.js.org/configuration/stats/#stats-presets.
const stats = options.stats === undefined ? 'normal' : options.stats; // eslint-disable-line no-undefined
const log =
stats === 'errors-only' ||
stats === 'errors-warnings' ||
stats === 'none' ||
stats === false
? () => {}
: console.log;

if (noDocument) {
console.log('no window.document found, will not HMR CSS');
log('no window.document found, will not HMR CSS');

return noop;
}
Expand All @@ -209,17 +220,17 @@ module.exports = function(moduleId, options) {
const reloaded = reloadStyle(src);

if (options.locals) {
console.log('[HMR] Detected local css modules. Reload all css');
log('[HMR] Detected local css modules. Reload all css');

reloadAll();

return;
}

if (reloaded && !options.reloadAll) {
console.log('[HMR] css reload %s', src.join(' '));
log('[HMR] css reload %s', src.join(' '));
} else {
console.log('[HMR] Reload all css');
log('[HMR] Reload all css');

reloadAll();
}
Expand Down
10 changes: 10 additions & 0 deletions src/loader-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
},
"reloadAll": {
"type": "boolean"
},
"stats": {
"anyOf": [
{
"type": "string"
},
{
"type": "boolean"
}
]
}
}
}