vite.config.ts 747 B

12345678910111213141516171819202122232425262728293031
  1. import { defineConfig, loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import Components from 'unplugin-vue-components/vite'
  4. import { VantResolver } from '@vant/auto-import-resolver'
  5. import { fileURLToPath, URL } from 'node:url'
  6. export default defineConfig(({ mode }) => {
  7. const env = loadEnv(mode, process.cwd())
  8. return {
  9. plugins: [
  10. vue(),
  11. Components({
  12. resolvers: [VantResolver()],
  13. }),
  14. ],
  15. resolve: {
  16. alias: {
  17. '@': fileURLToPath(new URL('./src', import.meta.url)),
  18. },
  19. },
  20. server: {
  21. port: 5174,
  22. proxy: {
  23. '/api': {
  24. target: env.VITE_API_PROXY_URL || 'http://localhost:8000',
  25. changeOrigin: true,
  26. },
  27. },
  28. },
  29. }
  30. })