import { defineConfig } from 'vite' | |
import react from '@vitejs/plugin-react' | |
import { resolve } from 'path' | |
// https://vitejs.dev/config/ | |
export default defineConfig({ | |
plugins: [react()], | |
base: '/', // 确保资源路径正确 | |
build: { | |
outDir: 'dist', | |
assetsDir: 'assets', | |
sourcemap: false, | |
// 禁用文件名哈希 | |
rollupOptions: { | |
output: { | |
entryFileNames: 'assets/[name].js', | |
chunkFileNames: 'assets/[name].js', | |
assetFileNames: 'assets/[name].[ext]' | |
} | |
} | |
}, | |
resolve: { | |
alias: { | |
'@': resolve(__dirname, './src') | |
} | |
}, | |
server: { | |
host: true, | |
port: 3000, | |
proxy: { | |
'/api': { | |
target: 'http://backend:8080', | |
changeOrigin: true, | |
rewrite: (path) => path.replace(/^\/api/, '/api') | |
} | |
} | |
} | |
}) |