vite.config.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. // 观澜前端构建配置(P11,用户令 2026-09-29)
  5. // · 产物落 `release/web/`:与现有静态件同住 release/,由后端/网关按同一前缀伺服;
  6. // · base './' —— 页面在网关子路径(/web/ 或 /detail/)下也要能取到自己的资源;
  7. // · 开发期代理:把 /api、/algorithm 转给现有 Python 后端与算法服务(真源仍在契约里)。
  8. export default defineConfig({
  9. plugins: [vue()],
  10. base: './',
  11. resolve: {
  12. alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
  13. },
  14. build: {
  15. outDir: fileURLToPath(new URL('../../release/web', import.meta.url)),
  16. emptyOutDir: true,
  17. sourcemap: false,
  18. target: 'es2020',
  19. },
  20. server: {
  21. port: 28110,
  22. proxy: {
  23. '/api': { target: 'http://127.0.0.1:18033', changeOrigin: true },
  24. '/algorithm': { target: 'http://127.0.0.1:18050', changeOrigin: true, rewrite: (p) => p.replace(/^\/algorithm/, '') },
  25. },
  26. },
  27. })