ProfilingPlugin 插件
webpackjsorg-main插件参考
ProfilingPlugin 插件
生成包含插件执行时间统计的 Chrome profile 文件。默认输出 events.json 文件。可以通过 outputPath 选项提供自定义文件路径。
注意:ProfilingPlugin 仅接受绝对路径。
选项
outputPath:自定义输出文件(json)的绝对路径。
用法:默认
js
new webpack.debug.ProfilingPlugin();
用法:自定义 outputPath
js
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
new webpack.debug.ProfilingPlugin({
outputPath: path.join(__dirname, "profiling/profileEvents.json"),
});
要查看 profile 文件:
- 使用
ProfilingPlugin运行 webpack。 - 打开 Chrome,进入 DevTools,然后转到
Performance标签页(原Timeline)。 - 将生成的文件(默认是
events.json)拖放到 profiler 中。
然后它将显示每个插件的时间线统计和调用!
帮助我们改进文档
发现翻译问题或内容错误?请告诉我们。
