vite.config.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig, loadEnv } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  7. import Unocss from 'unocss/vite'
  8. export default defineConfig(({ mode }) => {
  9. const env = loadEnv(mode, process.cwd(), '')
  10. return {
  11. base: '/',
  12. plugins: [
  13. vue(),
  14. Unocss(),
  15. AutoImport({
  16. resolvers: [ElementPlusResolver()],
  17. imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
  18. dts: 'src/auto-import.d.ts',
  19. }),
  20. Components({
  21. resolvers: [ElementPlusResolver()],
  22. dirs: ['src/components'],
  23. extensions: ['vue'],
  24. dts: 'src/components.d.ts',
  25. }),
  26. ],
  27. resolve: {
  28. alias: {
  29. '@': fileURLToPath(new URL('./src', import.meta.url)),
  30. },
  31. },
  32. server: {
  33. proxy: {
  34. [env.VITE_BASE_API]: {
  35. target: env.VITE_BASE_PATH,
  36. changeOrigin: true,
  37. },
  38. },
  39. hmr: {
  40. overlay: false,
  41. },
  42. },
  43. }
  44. })