feat: 项目加载优化

This commit is contained in:
Gsh
2026-02-01 00:30:44 +08:00
parent 3b6887dc2e
commit 11cbb1b612
29 changed files with 1490 additions and 299 deletions

View 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}`);
},
};
}