Skip to content

Commit edfc063

Browse files
authored
docs(api): add Compilation.hooks.statsFactory (#7215)
1 parent 935fd0c commit edfc063

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/content/api/compilation-hooks.mdx

+34
Original file line numberDiff line numberDiff line change
@@ -688,3 +688,37 @@ compilation.hooks.statsNormalize.tap('MyPlugin', (options) => {
688688
```
689689

690690
In this plugin, if the `myOption` is missing, it sets it to an empty array. Additionally, it ensures that `myOption` is always an array even if it was originally defined as a single value.
691+
692+
### statsFactory
693+
694+
This hook provides access to the StatsFactory class for specific options.
695+
696+
- Callback Parameters: `statsFactory` `options`
697+
698+
#### StatsFactory.hooks.extract
699+
700+
`HookMap`
701+
702+
- Callback Parameters: `object` `data` `context`
703+
704+
`data` contains the class. object is an object to which properties should be added. `context` provides contextual information, such as classes on the path.
705+
706+
Example:
707+
708+
```js
709+
compilation.hooks.statsFactory.tap('MyPlugin', (statsFactory, options) => {
710+
statsFactory.hooks.extract
711+
.for('compilation')
712+
.tap('MyPlugin', (object, compilation) => {
713+
object.customProperty = MyPlugin.getCustomValue(compilation);
714+
});
715+
});
716+
```
717+
718+
#### StatsFactory.hooks.result
719+
720+
`HookMap`
721+
722+
Called with the result on each level.
723+
724+
- Callback Parameters: `result` `context`

0 commit comments

Comments
 (0)