百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

speed-measure-webpack-plugin

> 编程语言
开源

⏱ 查看您的插件和加载器的速度(或不快),以便优化构建过程

2.4K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

⏱ 查看您的插件和加载器的速度(或不快),以便优化构建过程

Proudly maintained and developed by the team at 18ways.
AI-powered runtime localisation and i18n infrastructure.


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: ## Install ```bash npm install --save-dev speed-measure-webpack-plugin ``` or ```bash yarn add -D speed-measure-webpack-plugin ``` ## Requirements SMP requires at least **Node v6**. But otherwise, accepts **all webpack** versions (1, 2, 3, 4, and 5). To work on the repository itself and run the test suite, use **Node v18+**. ## Usage Change your webpack config from ```javascript const webpackConfig = { plugins: [new MyPlugin(), new MyOtherPlugin()], }; ``` to ```javascript 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](/examples) for some more examples. ## Options Pass these into the constructor, as an object: ```javascript 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. ```javascript const uglify = new UglifyJSPlugin(); const smp = new SpeedMeasurePlugin({ pluginNames: { customUglifyName: uglify, }, }); const webpackConfig = smp.wrap({ plugins: [uglify], }); ``` ### `options.excludedPlugins` Type: `Array`
Default: `[]` Excludes plugins from SMP's proxy wrapping. Entries can be: - a plugin name - a plugin constructor - a regular expression matched against plugin names Name matching checks both `options.pluginNames` aliases and constructor names. E.g. ```javascript const smp = new SpeedMeasurePlugin({ pluginNames: { customReactRefresh: reactRefreshPlugin, }, excludedPlugins: [ "customReactRefresh", MiniCssExtractPlugin, /SomeLegacyPlugin$/, ], }); ``` ### `options.loaderTopFiles` Type: `Number`
Default: `0` You can configure SMP to include the files that take the most time per loader, when using `outputFormat: 'humanVerbose'`. E.g., to show the top 10 files per loader: ```javascript const smp = new SpeedMeasurePlugin({ outputFormat: "humanVerbose", loaderTopFiles: 10, }); ``` ### `options.compareLoadersBuild` Type: `Object`
Default: `{}` This option gives you a comparison over time of the module count and time spent, per loader. This option provides more data when `outputFormat: "humanVerbose"`. Given a required `filePath` to store the build information, this option allows you to compare differences to your codebase over time. E.g. ```javascript const smp = new SpeedMeasurePlugin({ compareLoadersBuild: { filePath: "./buildInfo.json", }, }); ``` ### `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. ### `options.excludedLoaders` Type: `Array`
Default: `[]` When you enable `granularLoaderData`, SMP prepends its timing loader to each matching loader rule. Use this option to skip rules whose loader chain contains a matching loader name or regular expression. String matching checks both the original loader request and the normalized package name. E.g. ```javascript const smp = new SpeedMeasurePlugin({ granularLoaderData: true, excludedLoaders: ["thread-loader", /mini-css-extract-plugin/], }); ``` ## FAQ ### What does general output time mean? This tends to be down to webpack reading in from the file-system, but in general it's anything outside of what SMP can actually measure. ### What does modules without loaders mean? It means vanilla JS files, which webpack can handle out of the box. ## Contributing Contributors are welcome! Please check out the [CONTRIBUTING.md](./CONTRIBUTING.md). ## Migrating SMP follows [semver](https://semver.org/). If upgrading a major version, you can consult [the migration guide](./migration.md). ## License [MIT](/LICENSE) ## Contributors ✨ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Stephen Cook


scarletsky


牛さん


Thomas Bentkowski


Alan Agius


Ximing


Tan Li Hau

⚠️
Björn Brauer


Suraj Patel


Jm

⚠️ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •"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
  • •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
  • •a plugin name
  • •a plugin constructor
  • •a regular expression matched against plugin names
  • •loaders using separate processes (e.g. thread-loader)

> 标签

JavaScriptmeasurepluginspeedstats

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言