object = { boolean activeModules = true, boolean entries = false, function (number percentage, string message, [string] ...args) handler, boolean modules = true, number modulesCount = 500, boolean profile = false }
function (number percentage, string message, [string] ...args)
The ProgressPlugin
provides a way to customize how progress is reported during a compilation.
Create an instance of ProgressPlugin
and provide one of the allowed params.
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 compilationmessage
: a short description of the currently-executing hook...args
: zero or more additional strings describing the current progressconst handler = (percentage, message, ...args) => {
// e.g. Output each progress message directly to the console:
console.info(percentage, message, ...args);
};
new webpack.ProgressPlugin(handler);
object
When providing an object
to the ProgressPlugin
, following properties are supported:
activeModules
(boolean = false
): Shows active modules count and one active module in progress message.entries
(boolean = true
): Shows entries count in progress message.handler
(See Providing function)modules
(boolean = true
): Shows modules count in progress message.modulesCount
(number = 5000
): A minimum modules count to start with. Takes effect when modules
property is enabled.profile
(boolean = false
): Tells ProgressPlugin
to collect profile data for progress steps.dependencies
(boolean = true
): Shows the count of dependencies in progress message.dependenciesCount
(number = 10000
): A minimum dependencies count to start with. Takes effect when dependencies
property is enabled.percentBy
(string = null: 'entries' | 'dependencies' | 'modules' | null
): Tells ProgressPlugin
how to calculate progress percentage.new webpack.ProgressPlugin({
activeModules: false,
entries: true,
handler(percentage, message, ...args) {
// custom logic
},
modules: true,
modulesCount: 5000,
profile: false,
dependencies: true,
dependenciesCount: 10000,
percentBy: null
});
By default, progress percentage is calculated based on built modules count and total modules count: built / total
The total modules count is unknown in advance and changes during the build. This may cause inaccurate progress percentage.
To solve this problem ProgressPlugin
caches the last known total modules count and reuses this value on the next build. The first build will warm the cache but the following builds will use and update this value.
We recommend using
percentBy: 'entries'
setting for projects with multiple configured entry points. Percentage calculation will become more accurate because the amount of entry points is known in advance.
The following hooks report progress information to ProgressPlugin
.
Compiler
Compilation