-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
docs: add ProgressPlugin + progress reporting #2293
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
title: ProgressPlugin | ||
contributors: | ||
- elliottsj | ||
--- | ||
|
||
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: | ||
|
||
```js | ||
const handler = (percentage, message, ...args) => { | ||
// e.g. Output each progress message directly to the console: | ||
console.info(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. | ||
|
||
## Supported Hooks | ||
|
||
The following hooks report progress information to `ProgressPlugin`. | ||
|
||
T> _Hooks marked with * allow plugins to report progress information using `reportProgress`. For more, see [Plugin API: Reporting Progress](/api/plugins/#reporting-progress)_ | ||
|
||
**Compiler** | ||
|
||
* compilation | ||
* emit* | ||
* afterEmit* | ||
* done | ||
|
||
**Compilation** | ||
|
||
* buildModule | ||
* failedModule | ||
* succeedModule | ||
* finishModules* | ||
* seal* | ||
* optimizeDependenciesBasic* | ||
* optimizeDependencies* | ||
* optimizeDependenciesAdvanced* | ||
* afterOptimizeDependencies* | ||
* optimize* | ||
* optimizeModulesBasic* | ||
* optimizeModules* | ||
* optimizeModulesAdvanced* | ||
* afterOptimizeModules* | ||
* optimizeChunksBasic* | ||
* optimizeChunks* | ||
* optimizeChunksAdvanced* | ||
* afterOptimizeChunks* | ||
* optimizeTree* | ||
* afterOptimizeTree* | ||
* optimizeChunkModulesBasic* | ||
* optimizeChunkModules* | ||
* optimizeChunkModulesAdvanced* | ||
* afterOptimizeChunkModules* | ||
* reviveModules* | ||
* optimizeModuleOrder* | ||
* advancedOptimizeModuleOrder* | ||
* beforeModuleIds* | ||
* moduleIds* | ||
* optimizeModuleIds* | ||
* afterOptimizeModuleIds* | ||
* reviveChunks* | ||
* optimizeChunkOrder* | ||
* beforeChunkIds* | ||
* optimizeChunkIds* | ||
* afterOptimizeChunkIds* | ||
* recordModules* | ||
* recordChunks* | ||
* beforeHash* | ||
* afterHash* | ||
* recordHash* | ||
* beforeModuleAssets* | ||
* beforeChunkAssets* | ||
* additionalChunkAssets* | ||
* record* | ||
* additionalAssets* | ||
* optimizeChunkAssets* | ||
* afterOptimizeChunkAssets* | ||
* optimizeAssets* | ||
* afterOptimizeAssets* | ||
* afterSeal* | ||
|
||
## Source | ||
|
||
* [`ProgressPlugin` source](https://github.com/webpack/webpack/blob/master/lib/ProgressPlugin.js) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a showcase within your own plugin right? maybe provide a context e.g.
myPlugin.js
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can used inside of a plugin (e.g. progress-bar-webpack-plugin), but ProgressPlugin can also be used standalone, e.g.
I'd like to keep the initial "Usage" code snippet simple and consistent with the other plugin pages on the site.
I agree that it would be useful to showcase / link to examples of using ProgressPlugin within a parent plugin. What if I add an "Examples" section and link to ProgressPlugin usage within progress-bar-webpack-plugin / webpack-cli / webpack-command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the example you gave is much better in my opinion, maybe replace it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to include the
console.info()
line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think I should include the
module.exports = { plugins: [
part too? Leaving it out for now for consistency with the other plugin docs