vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { fileURLToPath, URL } from 'node:url'
  2. import path from 'path'
  3. import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite'
  4. import vue from '@vitejs/plugin-vue'
  5. import vueJsx from '@vitejs/plugin-vue-jsx'
  6. import AutoImport from 'unplugin-auto-import/vite'
  7. import Components from 'unplugin-vue-components/vite'
  8. import DefineOptions from 'unplugin-vue-define-options/vite'
  9. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
  10. import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-import'
  11. import Unocss from 'unocss/vite'
  12. export default defineConfig(({ mode }) => {
  13. const env = loadEnv(mode, process.cwd(), '')
  14. return {
  15. plugins: [
  16. vue(),
  17. vueJsx(),
  18. Unocss(),
  19. DefineOptions(),
  20. AutoImport({
  21. imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
  22. dts: 'src/auto-import.d.ts'
  23. }),
  24. Components({
  25. dirs: ['src/components'],
  26. extensions: ['vue'],
  27. dts: 'src/components.d.ts'
  28. }),
  29. createSvgIconsPlugin({
  30. iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')],
  31. symbolId: 'icon-[dir]-[name]'
  32. }),
  33. createStyleImportPlugin({
  34. resolves: [VxeTableResolve()]
  35. }),
  36. splitVendorChunkPlugin()
  37. ],
  38. resolve: {
  39. alias: {
  40. '@': fileURLToPath(new URL('./src', import.meta.url))
  41. }
  42. },
  43. server: {
  44. proxy: {
  45. [env.VITE_BASE_API]: {
  46. target: env.VITE_BASE_PATH,
  47. changeOrigin: true
  48. }
  49. },
  50. hmr: {
  51. overlay: false
  52. }
  53. }
  54. }
  55. })