Skip to content

Commit 3ad6ca2

Browse files
docs(plugins) document ProvidePlugin (#3102)
* docs(plugins) document ProvidePlugin * Update src/content/plugins/progress-plugin.md Co-Authored-By: Fernando Montoya <montogeek@gmail.com>
1 parent 21d04b5 commit 3ad6ca2

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

src/content/plugins/progress-plugin.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ contributors:
66
- byzyk
77
---
88

9+
`object` `function (percentage: number, message: string, ...args: string[])`
10+
911
The `ProgressPlugin` provides a way to customize how progress is reported during a compilation.
1012

1113
## Usage
1214

13-
Create an instance of `ProgressPlugin` with a handler function which will be called when hooks report progress:
15+
Create an instance of `ProgressPlugin` and provide one of the allowed params.
16+
17+
### Providing `function`
18+
19+
Provide a handler function which will be called when hooks report progress. `handler` function arguments:
20+
21+
- `percentage`: a number between 0 and 1 indicating the completion percentage of the compilation
22+
- `message`: a short description of the currently-executing hook
23+
- `...args`: zero or more additional strings describing the current progress
24+
1425

1526
```js
1627
const handler = (percentage, message, ...args) => {
@@ -21,10 +32,30 @@ const handler = (percentage, message, ...args) => {
2132
new webpack.ProgressPlugin(handler);
2233
```
2334

24-
- `handler` is a function which takes these arguments:
25-
- `percentage`: a number between 0 and 1 indicating the completion percentage of the compilation.
26-
- `message`: a short description of the currently-executing hook.
27-
- `...args`: zero or more additional strings describing the current progress.
35+
### Providing `object`
36+
37+
When providing an `object` to the `ProgressPlugin`, following properties are supported:
38+
39+
- `activeModules: boolean = true` show's active modules count and one active module in progress message
40+
- `entries: boolean = false` show's entries count in progress message
41+
- [`handler: function(percentage, message, ...args)`](#providing-function)
42+
- `modules: boolean = true` show's modules count in progress message
43+
- `modulesCount: number = 500` a minimum modules count to start with. Takes effect when `modules` property is enabled.
44+
- `profile: true | false | null = false` tells `ProgressPlugin` to collect profile data for progress steps.
45+
46+
47+
```js
48+
new webpack.ProgressPlugin({
49+
entries: true,
50+
modules: true,
51+
modulesCount: 100,
52+
profile: true,
53+
handler: (percentage, message, ...args) => {
54+
// custom logic
55+
}
56+
});
57+
```
58+
2859

2960
## Supported Hooks
3061

0 commit comments

Comments
 (0)