See how fast (or not) your plugins and loaders are, so you can optimise your builds
Clone or download
Latest commit cb9a8e4 Sep 24, 2018
Permalink
Failed to load latest commit information.
WrappedPlugin Fix memory leak in WrappedPlugin Apr 6, 2018
__tests__ Minor security fixes (through npm audit) Sep 24, 2018
examples Add in explicit support for Neutrino, and include an examples folder Mar 4, 2018
.gitignore Add in some functional tests, using Lerna to manage the dependencies … Mar 8, 2018
.npmignore Add in some functional tests, using Lerna to manage the dependencies … Mar 8, 2018
.prettierrc Add prettier for formatting Jan 30, 2018
.travis.yml Add in some automated scripts to pick up documentation issues Apr 6, 2018
LICENSE Change licence to very similar MIT, and improve README Feb 22, 2018
README.md Add in some automated scripts to pick up documentation issues Apr 6, 2018
colours.js Use chalk for colour output, in order for better terminal colour supp… Feb 20, 2018
index.js Set up SMP to work as expected with multi-configs, and generated configs Sep 24, 2018
jest.config.js Set up SMP to work as expected with multi-configs, and generated configs Sep 24, 2018
lerna.json Add in some functional tests, using Lerna to manage the dependencies … Mar 8, 2018
loader.js Granular loader data (#17) Feb 18, 2018
logo.svg Make the README a bit shinier Feb 3, 2018
migration.md Add a migration guide Feb 20, 2018
neutrino.js Add in explicit support for Neutrino, and include an examples folder Mar 4, 2018
output.js Use chalk for colour output, in order for better terminal colour supp… Feb 20, 2018
package-lock.json Minor security fixes (through npm audit) Sep 24, 2018
package.json Minor security fixes (through npm audit) Sep 24, 2018
preview.png Improve the output format to make it more readable Feb 6, 2018
utils.js Add webpack v4 support Mar 27, 2018
utils.test.js Granular loader data (#17) Feb 18, 2018

README.md

Speed Measure Plugin
(for webpack)


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:

Preview of Speed Measure Plugin's output

Install

npm install --save-dev speed-measure-webpack-plugin

or

yarn add -D speed-measure-webpack-plugin

Migrating

SMP follows semver. If upgrading a major version, you can consult the migration guide.

Requirements

SMP requires at least Node v6. But otherwise, accepts all webpack versions (1, 2, 3, and 4).

Usage

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.

Check out the examples folder for some more examples.

Options

Pass these into the constructor, as an object:

const smp = new SpeedMeasurePlugin(options);

options.disable

Type: Boolean
Default: false

If truthy, this plugin does nothing at all.

{ disable: !process.env.MEASURE } allows opt-in measurements with MEASURE=true npm run build.

options.outputFormat

Type: 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 output
  • If a function, it will call the function with the JSON blob, and output the response

options.outputTarget

Type: String|Function
Default: console.log

  • If a string, it specifies the path to a file to output to.
  • If a function, it will call the function with the output as the first parameter

options.pluginNames

Type: 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

By default, SMP measures loaders in groups. If truthy, this plugin will give per-loader timing information.

This flag is experimental. Some loaders will have inaccurate results:

  • loaders using separate processes (e.g. thread-loader)
  • loaders emitting file output (e.g. file-loader)

We will find solutions to these issues before removing the (experimental) flag on this option.

License

MIT