mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-23 23:39:47 +08:00
feat(projects): 添加全局组件自动引入注册
This commit is contained in:
21
build/plugins/auto-import.ts
Normal file
21
build/plugins/auto-import.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import Icons from 'unplugin-icons/vite';
|
||||
import IconsResolver from 'unplugin-icons/resolver';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
|
||||
|
||||
export default (srcPath: string) => {
|
||||
return [
|
||||
Icons({
|
||||
compiler: 'vue3',
|
||||
customCollections: {
|
||||
custom: FileSystemIconLoader(`${srcPath}/assets/svg`),
|
||||
},
|
||||
scale: 1,
|
||||
defaultClass: 'inline-block',
|
||||
}),
|
||||
Components({
|
||||
dts: true,
|
||||
resolvers: [IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })],
|
||||
}),
|
||||
];
|
||||
};
|
@ -14,7 +14,7 @@ export default (srcPath: string) => {
|
||||
defaultClass: 'inline-block',
|
||||
}),
|
||||
Components({
|
||||
dts: false,
|
||||
dts: true,
|
||||
resolvers: [IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })],
|
||||
}),
|
||||
];
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { ConfigEnv, PluginOption } from 'vite';
|
||||
import vue from './vue';
|
||||
import html from './html';
|
||||
import iconify from './iconify';
|
||||
import autoImport from './auto-import';
|
||||
import windicss from './windicss';
|
||||
import mock from './mock';
|
||||
import visualizer from './visualizer';
|
||||
@ -17,7 +17,7 @@ export function setupVitePlugins(
|
||||
srcPath: string,
|
||||
viteEnv: ImportMetaEnv
|
||||
): (PluginOption | PluginOption[])[] {
|
||||
const plugins = [vue, html(configEnv), ...iconify(srcPath), windicss, mock];
|
||||
const plugins = [vue, html(configEnv), ...autoImport(srcPath), windicss, mock];
|
||||
|
||||
if (configEnv.command === 'build' && viteEnv.VITE_VISUALIZER === 'true') {
|
||||
plugins.push(visualizer);
|
||||
|
Reference in New Issue
Block a user