|
| 1 | +--- |
| 2 | +title: ProgressPlugin |
| 3 | +contributors: |
| 4 | + - elliottsj |
| 5 | +--- |
| 6 | + |
| 7 | +The `ProgressPlugin` provides a way to customize how progress is reported during a compilation. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +Create an instance of `ProgressPlugin` with a handler function which will be called when hooks report progress: |
| 12 | + |
| 13 | +```js |
| 14 | +const handler = (percentage, message, ...args) => { |
| 15 | + // e.g. Output each progress message directly to the console: |
| 16 | + console.info(percentage, message, ...args); |
| 17 | +}; |
| 18 | + |
| 19 | +new webpack.ProgressPlugin(handler); |
| 20 | +``` |
| 21 | + |
| 22 | +* `handler` is a function which takes these arguments: |
| 23 | + * `percentage`: a number between 0 and 1 indicating the completion percentage of the compilation. |
| 24 | + * `message`: a short description of the currently-executing hook. |
| 25 | + * `...args`: zero or more additional strings describing the current progress. |
| 26 | + |
| 27 | +## Supported Hooks |
| 28 | + |
| 29 | +The following hooks report progress information to `ProgressPlugin`. |
| 30 | + |
| 31 | +T> _Hooks marked with * allow plugins to report progress information using `reportProgress`. For more, see [Plugin API: Reporting Progress](/api/plugins/#reporting-progress)_ |
| 32 | + |
| 33 | +**Compiler** |
| 34 | + |
| 35 | +* compilation |
| 36 | +* emit* |
| 37 | +* afterEmit* |
| 38 | +* done |
| 39 | + |
| 40 | +**Compilation** |
| 41 | + |
| 42 | +* buildModule |
| 43 | +* failedModule |
| 44 | +* succeedModule |
| 45 | +* finishModules* |
| 46 | +* seal* |
| 47 | +* optimizeDependenciesBasic* |
| 48 | +* optimizeDependencies* |
| 49 | +* optimizeDependenciesAdvanced* |
| 50 | +* afterOptimizeDependencies* |
| 51 | +* optimize* |
| 52 | +* optimizeModulesBasic* |
| 53 | +* optimizeModules* |
| 54 | +* optimizeModulesAdvanced* |
| 55 | +* afterOptimizeModules* |
| 56 | +* optimizeChunksBasic* |
| 57 | +* optimizeChunks* |
| 58 | +* optimizeChunksAdvanced* |
| 59 | +* afterOptimizeChunks* |
| 60 | +* optimizeTree* |
| 61 | +* afterOptimizeTree* |
| 62 | +* optimizeChunkModulesBasic* |
| 63 | +* optimizeChunkModules* |
| 64 | +* optimizeChunkModulesAdvanced* |
| 65 | +* afterOptimizeChunkModules* |
| 66 | +* reviveModules* |
| 67 | +* optimizeModuleOrder* |
| 68 | +* advancedOptimizeModuleOrder* |
| 69 | +* beforeModuleIds* |
| 70 | +* moduleIds* |
| 71 | +* optimizeModuleIds* |
| 72 | +* afterOptimizeModuleIds* |
| 73 | +* reviveChunks* |
| 74 | +* optimizeChunkOrder* |
| 75 | +* beforeChunkIds* |
| 76 | +* optimizeChunkIds* |
| 77 | +* afterOptimizeChunkIds* |
| 78 | +* recordModules* |
| 79 | +* recordChunks* |
| 80 | +* beforeHash* |
| 81 | +* afterHash* |
| 82 | +* recordHash* |
| 83 | +* beforeModuleAssets* |
| 84 | +* beforeChunkAssets* |
| 85 | +* additionalChunkAssets* |
| 86 | +* record* |
| 87 | +* additionalAssets* |
| 88 | +* optimizeChunkAssets* |
| 89 | +* afterOptimizeChunkAssets* |
| 90 | +* optimizeAssets* |
| 91 | +* afterOptimizeAssets* |
| 92 | +* afterSeal* |
| 93 | + |
| 94 | +## References |
| 95 | + |
| 96 | +### Source |
| 97 | + |
| 98 | +* [`ProgressPlugin` source](https://github.com/webpack/webpack/blob/master/lib/ProgressPlugin.js) |
0 commit comments