12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import { fileURLToPath, URL } from 'node:url'
- import path from 'path'
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import vueJsx from '@vitejs/plugin-vue-jsx'
- import Icons from 'unplugin-icons/vite'
- import IconsResolver from 'unplugin-icons/resolver'
- 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 { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
- import Unocss from 'unocss/vite'
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd(), '')
- return {
- plugins: [
- vue(),
- vueJsx(),
- Unocss(),
- DefineOptions(),
- AutoImport({
- resolvers: [
- ElementPlusResolver(),
- // 自动导入图标组件
- IconsResolver({
- prefix: 'Icon'
- })
- ],
- imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
- dts: 'src/auto-import.d.ts'
- }),
- Components({
- resolvers: [
- ElementPlusResolver(),
- // 自动注册图标组件
- IconsResolver({
- enabledCollections: ['ep']
- })
- ],
- dirs: ['src/components'],
- extensions: ['vue'],
- dts: 'src/components.d.ts'
- }),
- Icons({
- autoInstall: true
- }),
- createSvgIconsPlugin({
- iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')],
- symbolId: 'icon-[dir]-[name]'
- }),
- createStyleImportPlugin({
- resolves: [VxeTableResolve()]
- })
- ],
- 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
- }
- },
- build: {
- sourcemap: !!env.VITE_SENTRY_DSN,
- rollupOptions: {
- output: {
- manualChunks: (id: string) => {
- if (id.includes('node_modules')) {
- return 'vender'
- }
- }
- }
- }
- }
- }
- })
|