函数执行性能统计插件。
此插件用于函数执行性能统计,通过注入统计代码的方式计算执行耗时发现慢函数。
首先在项目中安装插件依赖。示例:
pnpm install -D @lzwme/feps-webpack-plugin
然后在 webpack
配置中添加插件配置。示例:
webpack.config.js
// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const FEPSPlugin = require('@lzwme/feps-webpack-plugin');
module.exports = {
plugins: [
new FEPSPlugin({
// debug: true,
// disabled: false,
rootDir: __dirname,
timeLimit: 50,
logger: 'console.warn', // 'globalThis.logger.report',
include: [/\.(tsx?|jsx?)$/],
exclude: ['node_modules', /\.ignore\./],
excludeNodeType: [],
}),
],
};
Name | Type | Default | Description |
---|---|---|---|
debug |
{boolean} |
false |
debug for print details info |
disabled |
{boolean} |
false |
Disable the plugin |
rootDir |
{String} |
process.cwd() |
Project root directory |
logger |
{String} |
console.warn |
指定打印慢函数日志信息的全局方法 |
timeLimit |
{Number} |
50 |
慢函数执行耗时阈值。 执行时间大于该值则会调用 options.logger 指定的全局方法 |
include |
{(String | RegExp)[]} |
[/(jsx?|tsx?)$/] |
Specifies a list of patterns that match files to be included in compilation |
exclude |
{(String | RegExp)[]} |
['node_modules'] |
Specifies a list of patterns that match files to be excluded from compilation |
excludeNodeType |
{AnyNode[]} |
[] |
Specifies a list of ast node types that to be excluded |
git clone https://github.com/lzwme/feps-webpack-plugin.git
pnpm install
# start for examples/webpack5-example
pnpm run dev
# enable cache by filesystem
pnpm run dev --cache
# first delete the dist and cache directories
pnpm run dev --reset
@lzwme/feps-webpack-plugin
is released under the MIT license.
该插件由志文工作室开发和维护。