From 666576fefa2371a44b7e84e444e74eed15563039 Mon Sep 17 00:00:00 2001 From: songshankun <songshankun@foxmail.com> Date: 星期三, 25 十月 2023 18:03:43 +0800 Subject: [PATCH] chore: 配置组件库/图标库/axios --- vite.config.ts | 44 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 35 insertions(+), 9 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 68f2fe2..03be1f2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,25 +1,51 @@ -import { fileURLToPath, URL } from 'node:url' +import path from 'path' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' +import IconsResolver from 'unplugin-icons/resolver' +import Icons from 'unplugin-icons/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' + +const pathSrc = path.resolve(__dirname, 'src') // https://vitejs.dev/config/ export default defineConfig({ + resolve: { + alias: { + '@': pathSrc + } + }, plugins: [ vue(), // element plus 鑷姩瀵煎叆 AutoImport({ - resolvers: [ElementPlusResolver()] + // 鑷姩瀵煎叆 Vue 鐩稿叧鍑芥暟锛屽锛歳ef, reactive, toRef 绛� + imports: ['vue'], + // 鑷姩瀵煎叆 Element Plus 鐩稿叧鍑芥暟锛屽锛欵lMessage, ElMessageBox... (甯︽牱寮�) + resolvers: [ + ElementPlusResolver(), + // 鑷姩瀵煎叆鍥炬爣缁勪欢 + IconsResolver({ + prefix: 'Icon' + }) + ], + + dts: path.resolve(pathSrc, 'auto-imports.d.ts') }), Components({ - resolvers: [ElementPlusResolver()] + resolvers: [ + // 鑷姩娉ㄥ唽鍥炬爣缁勪欢 + IconsResolver({ + enabledCollections: ['ep'] + }), + // 鑷姩瀵煎叆 Element Plus 缁勪欢 + ElementPlusResolver() + ], + dts: path.resolve(pathSrc, 'components.d.ts') + }), + Icons({ + autoInstall: true }) - ], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)) - } - } + ] }) -- Gitblit v1.8.0