vite.config.js 671 B

12345678910111213141516171819202122232425262728
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig, loadEnv } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. // https://vitejs.dev/config/
  5. export default defineConfig(mode => {
  6. const env = loadEnv(mode.mode, process.cwd())
  7. const proxytarget = env.VITE_PROXY_TARGET || 'http://localhost:8080'
  8. return {
  9. plugins: [vue()],
  10. resolve: {
  11. alias: {
  12. '@': fileURLToPath(new URL('./src', import.meta.url))
  13. }
  14. },
  15. server: {
  16. proxy: {
  17. [env.VITE_API_URL]: {
  18. target: proxytarget,
  19. changeOrigin: true,
  20. rewrite: path => path.replace(env.VITE_API_URL, '')
  21. }
  22. }
  23. }
  24. }
  25. })