vite.config.ts 987 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { fileURLToPath, URL } from 'node:url'
  2. import path from 'node:path'
  3. import { defineConfig, loadEnv } from 'vite'
  4. import vue from '@vitejs/plugin-vue'
  5. import vueDevTools from 'vite-plugin-vue-devtools'
  6. const __dirname = path.dirname(fileURLToPath(import.meta.url))
  7. // https://vite.dev/config/
  8. export default defineConfig(({ command, mode }) => {
  9. const env = loadEnv(mode,process.cwd(),'');
  10. const port = parseInt(env.VITE_APP_PORT) || 5173
  11. const apiTarget = env.VITE_APP_API_BASEURL || 'http://localhost:3000'
  12. return {
  13. plugins: [
  14. vue(),
  15. vueDevTools(),
  16. ],
  17. resolve: {
  18. alias: {
  19. '@': path.resolve(__dirname, './src')
  20. },
  21. },
  22. server: {
  23. port: port,
  24. strictPort: true,
  25. proxy: {
  26. "/api": {
  27. target:apiTarget,
  28. changeOrigin:true
  29. }
  30. }
  31. }
  32. }
  33. })