vite.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig, loadEnv } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueDevTools from 'vite-plugin-vue-devtools'
  5. import AutoImport from 'unplugin-auto-import/vite'
  6. import Components from 'unplugin-vue-components/vite'
  7. import { TDesignResolver } from 'unplugin-vue-components/resolvers'
  8. // https://vitejs.dev/config/
  9. export default defineConfig(({ command, mode }) => {
  10. const env = loadEnv(mode, process.cwd(), '')
  11. return {
  12. plugins: [
  13. vue(),
  14. vueDevTools(),
  15. AutoImport({
  16. resolvers: [
  17. TDesignResolver({
  18. library: 'vue-next'
  19. })
  20. ]
  21. }),
  22. Components({
  23. resolvers: [
  24. TDesignResolver({
  25. library: 'vue-next'
  26. })
  27. ]
  28. }),
  29. ],
  30. resolve: {
  31. alias: {
  32. '@': fileURLToPath(new URL('./src', import.meta.url))
  33. }
  34. },
  35. server: {
  36. proxy: {
  37. '/api': {
  38. target: env.VITE_PROXY_ENDPOINT,
  39. changeOrigin: true,
  40. rewrite: (path) => path.replace(/^\/api/, '')
  41. }
  42. }
  43. }
  44. }
  45. })