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

@@ -10,15 +10,21 @@ import Components from 'unplugin-vue-components/vite';
import viteCompression from 'vite-plugin-compression';
import envTyped from 'vite-plugin-env-typed';
import fontAwesomePlugin from './fontawesome';
import gitHashPlugin from './git-hash';
import preloadPlugin from './preload';
import createSvgIcon from './svg-icon';
import versionHtmlPlugin from './version-html';
const root = path.resolve(__dirname, '../../');
function plugins({ mode, command }: ConfigEnv): PluginOption[] {
return [
versionHtmlPlugin(), // 最先处理 HTML 版本号
gitHashPlugin(),
preloadPlugin(),
UnoCSS(),
fontAwesomePlugin(),
envTyped({
mode,
envDir: root,
@@ -35,7 +41,18 @@ function plugins({ mode, command }: ConfigEnv): PluginOption[] {
dts: path.join(root, 'types', 'auto-imports.d.ts'),
}),
Components({
resolvers: [ElementPlusResolver()],
resolvers: [
ElementPlusResolver(),
// 自动导入 FontAwesomeIcon 组件
(componentName) => {
if (componentName === 'FontAwesomeIcon') {
return {
name: 'FontAwesomeIcon',
from: '@/components/FontAwesomeIcon/index.vue',
};
}
},
],
dts: path.join(root, 'types', 'components.d.ts'),
}),
createSvgIcon(command === 'build'),