webpack-summary v2.1.1
Webpack Summary
Webpack plugin for displaying a short summary at the end of the build process.
Useful for replacing the many lines of Webpack's output to the terminal with a single, concise, customizable line containing all the info you need.
Install
$ npm install --save webpack-summary
Usage
import SummaryPlugin from 'webpack-summary';
const options = {/* ... */};
export default {
/* ... */
plugins: [
/* ... */
new SummaryPlugin ( options )
]
};
Options
The optional options object has the following shape:
{
normal: {
entry: template | false,
chunk: template | false
},
watching: {
entry: template | false,
chunk: template | false
}
}
And it defines the templates to use when in watching mode or not.
If a falsy value is used as a template it will not be rendered.
Template
A template is just a string that may contain placeholders, that look like {foo}
or {foo.bar}
, that will be replaced with the appropriate value.
Some example templates:
[{entry.name}] Bundled into "{entry.asset}" ({entry.size.MB}MB) in {time.s}s
Bundle rebuilt in {time.s}s.
Webpack {stats.version} - Bundled in {time.s} seconds.
Bundled in {time.m} minutes. {stats.errors.length} errors. {stats.warnings.length} warnings.
Placeholders
A placeholder is just a path that retrieves a value from the following object:
{
stats, // Raw Webpack stats file
size: { // Size of the bundle, available in different units
B, // Number of bytes
KB, // Number of kilobytes
MB // Number of megabytes
} ,
time: { // Time it took to bundle, available in different units
ms, // Milliseconds
s, // Seconds
m // Minutes
},
entries: [{ // Array of data about each entries
name, // Name of the entry
asset, // Name of the bundled entry file
size: { // Size of the bundled entry file
B, // Number of bytes
KB, // Number of kilobytes
MB // Number of megabytes
}
}]
}
There are also two special paths, entry
and chunk
, each available in their related templates.
License
MIT © Fabio Spampinato