vite.config.mts 782 B

123456789101112131415161718192021222324252627282930313233
  1. import {
  2. defaultImportmapOptions,
  3. defineConfig,
  4. getDefaultPwaOptions,
  5. loadAndConvertEnv,
  6. } from '@vben/vite-config';
  7. export default defineConfig(async () => {
  8. const { appTitle, port, ...envConfig } = await loadAndConvertEnv();
  9. return {
  10. application: {
  11. ...envConfig,
  12. importmap: false,
  13. importmapOptions: defaultImportmapOptions,
  14. pwa: false,
  15. pwaOptions: getDefaultPwaOptions(appTitle),
  16. },
  17. vite: {
  18. server: {
  19. port,
  20. proxy: {
  21. '/api': {
  22. changeOrigin: true,
  23. rewrite: (path) => path.replace(/^\/api/, ''),
  24. // 代理目标地址 - backend-mock 项目
  25. target: 'http://localhost:5320/api',
  26. ws: true,
  27. },
  28. },
  29. },
  30. },
  31. };
  32. });