Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(plugins) document ProvidePlugin #3102

Merged
merged 3 commits into from
Jun 14, 2019
Merged
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
41 changes: 36 additions & 5 deletions src/content/plugins/progress-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@ contributors:
- byzyk
---

`object` `function (percentage: number, message: string, ...args: string[])`

The `ProgressPlugin` provides a way to customize how progress is reported during a compilation.

## Usage

Create an instance of `ProgressPlugin` with a handler function which will be called when hooks report progress:
Create an instance of `ProgressPlugin` and provide one of the allowed params.

### Providing `function`

Provide a handler function which will be called when hooks report progress. `handler` function arguments:

- `percentage`: a number between 0 and 1 indicating the completion percentage of the compilation
- `message`: a short description of the currently-executing hook
- `...args`: zero or more additional strings describing the current progress
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero or more additional strings

That doesn't say anything haha, What is it exactly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅
Yes unfortunately source code doesn't have them used. I think it's reserved to avoid breaking changes in future when plugin is changed



```js
const handler = (percentage, message, ...args) => {
Expand All @@ -21,10 +32,30 @@ const handler = (percentage, message, ...args) => {
new webpack.ProgressPlugin(handler);
```

- `handler` is a function which takes these arguments:
- `percentage`: a number between 0 and 1 indicating the completion percentage of the compilation.
- `message`: a short description of the currently-executing hook.
- `...args`: zero or more additional strings describing the current progress.
### Providing `object`

When providing an `object` to the `ProgressPlugin`, next properties are supported:
EugeneHlushko marked this conversation as resolved.
Show resolved Hide resolved

- `activeModules: boolean = true` show's active modules count and one active module in progress message
- `entries: boolean = false` show's entries count in progress message
- [`handler: function(percentage, message, ...args)`](#providing-function)
- `modules: boolean = true` show's modules count in progress message
- `modulesCount: number = 500` a minimum modules count to start with. Takes effect when `modules` property is enabled.
- `profile: true | false | null = false` tells `ProgressPlugin` to collect profile data for progress steps.


```js
new webpack.ProgressPlugin({
entries: true,
modules: true,
modulesCount: 100,
profile: true,
handler: (percentage, message, ...args) => {
// custom logic
}
});
```


## Supported Hooks

Expand Down