Skip to content

Commit 752730c

Browse files
authored
docs(api): add Compilation.hooks.statsPreset (#7211)
1 parent 9b95f35 commit 752730c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/content/api/compilation-hooks.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,21 @@ Executed after setting up a child compiler.
650650
### normalModuleLoader
651651

652652
Since webpack v5 `normalModuleLoader` hook was removed. Now to access the loader use `NormalModule.getCompilationHooks(compilation).loader` instead.
653+
654+
### statsPreset
655+
656+
`HookMap`
657+
658+
This HookMap is like a list of actions that gets triggered when a preset is used. It takes in an options object. When a plugin manages a preset, it should change settings in this object carefully without replacing existing ones.
659+
660+
- Callback Parameters: `options` `context`
661+
662+
Here's an illustrative plugin example:
663+
664+
```js
665+
compilation.hooks.statsPreset.for('my-preset').tap('MyPlugin', (options) => {
666+
if (options.all === undefined) options.all = true;
667+
});
668+
```
669+
670+
This plugin ensures that for the preset `'my-preset'`, if the `all` option is undefined, it defaults to true.

0 commit comments

Comments
 (0)