feat: 项目加载优化
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user