import { fileURLToPath, URL } from 'node:url' import path from 'path' import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import DefineOptions from 'unplugin-vue-define-options/vite' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-import' import Unocss from 'unocss/vite' export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') return { plugins: [ vue(), vueJsx(), Unocss(), DefineOptions(), AutoImport({ imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'], dts: 'src/auto-import.d.ts' }), Components({ dirs: ['src/components'], extensions: ['vue'], dts: 'src/components.d.ts' }), createSvgIconsPlugin({ iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')], symbolId: 'icon-[dir]-[name]' }), createStyleImportPlugin({ resolves: [VxeTableResolve()] }), splitVendorChunkPlugin() ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, server: { proxy: { [env.VITE_BASE_API]: { target: env.VITE_BASE_PATH, changeOrigin: true } }, hmr: { overlay: false } } } })