-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
master1lan
committed
Feb 14, 2023
1 parent
f58c8a7
commit ffcb6fa
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| function getBulidTime() { | ||
| const buildTimeName = `build takes time`; | ||
| return { | ||
| name: "get-bulid-time", | ||
| enforce: "pre||post", // 插件执行的顺序,pre表示在alias之后,在vite的核心插件之前,post在核心插件之后 | ||
| // pre 首批被执行的插件,会在@rollup/plugin-alias插件执行之后执行。 | ||
| // normal(默认值) 第二批配执行的插件,会在vite的build阶段之前被执行,可以根据配置判断是否需要处理当前文件的代码。 | ||
| // post 会在vite的build阶段之后被执行,进行代码构建方面的工作(minimize、代码分析...)。 | ||
| apply: "build", //值可以是 build 或 serve 亦可以是一个函数,指明它们仅在 build 或 serve 模式时调用;如果不增加这个属性就会在run dev的时候也会输出buildStart中的信息 | ||
| buildStart() { | ||
| console.time(buildTimeName); | ||
| }, | ||
| buildEnd() { | ||
| // console.log('在构建阶段结束后被调用,此处构建结束只是代表所有模块转义完成;') | ||
| // console.timeEnd('time') | ||
| }, | ||
| closeBundle() { | ||
| // 在服务器关闭时被调用 | ||
| console.timeEnd(buildTimeName); | ||
| }, | ||
| }; | ||
| } | ||
| export default getBulidTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters