chore: update project files
This commit is contained in:
@@ -9,16 +9,23 @@ export default defineConfig({
|
||||
'@': resolve(__dirname, 'src')
|
||||
}
|
||||
},
|
||||
// 生产/开发环境配置
|
||||
base: process.env.NODE_ENV === 'production' ? '/' : '/',
|
||||
|
||||
// 开发服务器配置
|
||||
server: {
|
||||
port: 5173,
|
||||
port: 8081,
|
||||
host: '0.0.0.0', // 允许外部访问
|
||||
allowedHosts: true, // 允许所有主机访问
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
// 开发时代理到本地后端(统一为 localhost:8080)
|
||||
target: process.env.VITE_APP_API_URL || 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
// 确保后端返回的 Set-Cookie 可被前端域接收与发送
|
||||
// 后端服务器路径已经包含 /api,所以不需要 rewrite
|
||||
// 前端请求 /api/xxx 会转发到 http://localhost:8080/api/xxx
|
||||
// 调试时将 cookie 域改写为 localhost
|
||||
cookieDomainRewrite: 'localhost',
|
||||
cookiePathRewrite: '/',
|
||||
configure: (proxy, _options) => {
|
||||
@@ -39,8 +46,32 @@ export default defineConfig({
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 生产环境构建配置
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
assetsDir: 'assets'
|
||||
assetsDir: 'static',
|
||||
// 代码分割优化
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
'vue-vendor': ['vue', 'vue-router', 'pinia'],
|
||||
'element-plus': ['element-plus', '@element-plus/icons-vue'],
|
||||
'utils': ['axios']
|
||||
}
|
||||
}
|
||||
},
|
||||
// 生产环境移除 console
|
||||
// 注意:如果使用 terser,需要安装: npm install -D terser
|
||||
// 暂时使用 esbuild(默认,更快)
|
||||
minify: 'esbuild',
|
||||
// terserOptions: {
|
||||
// compress: {
|
||||
// drop_console: true,
|
||||
// drop_debugger: true
|
||||
// }
|
||||
// },
|
||||
// 块大小警告限制
|
||||
chunkSizeWarningLimit: 1000
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user