import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import { resolve, dirname } from 'path' import { fileURLToPath } from 'url' const __filename = fileURLToPath(import.meta.url) const __dirname = dirname(__filename) export default defineConfig({ plugins: [vue(), vueJsx()], resolve: { alias: { '@': resolve(__dirname, 'src') } }, server: { port: 5001, host: true, cors: true, proxy: { '/api': { target: 'http://localhost:8080', changeOrigin: true, rewrite: (path: string) => path.replace(/^\/api/, '') }, // 代理共享模块请求到 shared 服务 '/shared': { target: 'http://localhost:5000', changeOrigin: true } } }, build: { outDir: 'dist', sourcemap: true, rollupOptions: { output: { manualChunks: { 'vue-vendor': ['vue', 'vue-router', 'pinia'], 'element-plus': ['element-plus'] } } } } })