$ npm install speed-measure-webpack-plugin
The first step to optimising your webpack build speed, is to know where to focus your attention.
This plugin measures your webpack build speed, giving an output like this:
npm install --save speed-measure-webpack-plugin
or
yarn add speed-measure-webpack-plugin
Change your webpack config from
const webpackConfig = {
plugins: [
new MyPlugin(),
new MyOtherPlugin()
]
}
to
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const smp = new SpeedMeasurePlugin();
const webpackConfig = smp.wrap({
plugins: [
new MyPlugin(),
new MyOtherPlugin()
]
});
and you're done! SMP will now be printing timing output to the console by default
Options are (optionally) passed in to the constructor
const smp = new SpeedMeasurePlugin(options);
options.disableType: Boolean
Default: false
If truthy, this plugin does nothing at all. It is recommended to set this with something similar to { disable: !process.env.MEASURE } to allow opt-in measurements with a MEASURE=true npm run build
options.outputFormatType: String|Function
Default: "human"
Determines in what format this plugin prints its measurements
"json" - produces a JSON blob"human" - produces a human readable output"humanVerbose" - produces a more verbose version of the human readable outputoptions.outputTargetType: String|Function
Default: console.log
options.pluginNamesType: Object
Default: {}
By default, SMP derives plugin names through plugin.constructor.name. For some
plugins this doesn't work (or you may want to override this default). This option
takes an object of pluginName: PluginConstructor, e.g.
const uglify = new UglifyJSPlugin();
const smp = new SpeedMeasurePlugin({
pluginNames: {
customUglifyName: uglify
}
});
const webpackConfig = smp.wrap({
plugins: [
uglify
]
});
options.granularLoaderData (experimental)Type: Boolean
Default: false
If truthy, this plugin will attempt to break down the loader timing data to give per-loader timing information.
Points of note that the following loaders will have inaccurate results in this mode:
thread-loader) - these make it difficult to get timing information on the subsequent loaders, as they're not attached to the main threadfile-loader) - the time taken in outputting the actual file is not included in the running time of the loaderThese are restrictions from technical limitations - ideally we would find solutions to these problems before removing the (experimental) flag on this options
© 2010 - cnpmjs.org x YWFE | Home | YWFE