From 5278c6a21d667a67ddb618976b6ecd01ec2f731a Mon Sep 17 00:00:00 2001 From: EugeneHlushko Date: Thu, 6 Jun 2019 15:20:48 +0300 Subject: [PATCH 1/2] docs(plugins) document ProvidePlugin --- src/content/plugins/progress-plugin.md | 41 ++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/content/plugins/progress-plugin.md b/src/content/plugins/progress-plugin.md index 0f93d9c9e40e..06da2a1d3beb 100644 --- a/src/content/plugins/progress-plugin.md +++ b/src/content/plugins/progress-plugin.md @@ -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 + ```js const handler = (percentage, message, ...args) => { @@ -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: + +- `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 From 1fa0cc7e7dcfa5af7b3b120eeac239fd6061d97e Mon Sep 17 00:00:00 2001 From: Eugene Hlushko Date: Tue, 11 Jun 2019 16:24:57 +0300 Subject: [PATCH 2/2] Update src/content/plugins/progress-plugin.md Co-Authored-By: Fernando Montoya --- src/content/plugins/progress-plugin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/plugins/progress-plugin.md b/src/content/plugins/progress-plugin.md index 06da2a1d3beb..a8a0115f9e94 100644 --- a/src/content/plugins/progress-plugin.md +++ b/src/content/plugins/progress-plugin.md @@ -34,7 +34,7 @@ new webpack.ProgressPlugin(handler); ### Providing `object` -When providing an `object` to the `ProgressPlugin`, next properties are supported: +When providing an `object` to the `ProgressPlugin`, following properties are supported: - `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