feat: 项目加载优化
This commit is contained in:
20
Yi.Ai.Vue3/.build/plugins/version-html.ts
Normal file
20
Yi.Ai.Vue3/.build/plugins/version-html.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { APP_VERSION, APP_NAME } from '../../src/config/version';
|
||||
|
||||
/**
|
||||
* Vite 插件:在 HTML 中注入版本号
|
||||
* 替换 HTML 中的占位符为实际版本号
|
||||
*/
|
||||
export default function versionHtmlPlugin(): Plugin {
|
||||
return {
|
||||
name: 'vite-plugin-version-html',
|
||||
enforce: 'pre',
|
||||
transformIndexHtml(html) {
|
||||
// 替换 HTML 中的版本占位符
|
||||
return html
|
||||
.replace(/%APP_NAME%/g, APP_NAME)
|
||||
.replace(/%APP_VERSION%/g, APP_VERSION)
|
||||
.replace(/%APP_FULL_NAME%/g, `${APP_NAME} ${APP_VERSION}`);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user