Files
thebet365/apps/player/vite.config.ts
Mars 43fa8ebef0 fix(dev): 本地 API 默认端口改为 3100 避开 Windows 保留段
Hyper-V 常保留 2960-3059,3000 会 EACCES;ensure-port-free 与 Vite 代理从 apps/api/.env 读取 PORT
2026-06-23 15:11:50 +08:00

48 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { resolveApiDevTarget } from '../../scripts/dev-api-target.mjs';
const apiTarget = resolveApiDevTarget();
export default defineConfig({
plugins: [vue()],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) {
if (id.includes('/src/i18n/zh-CN')) return 'i18n-zh-CN';
if (id.includes('/src/i18n/en-US')) return 'i18n-en-US';
if (id.includes('/src/i18n/ms-MY')) return 'i18n-ms-MY';
return undefined;
}
if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
return 'vue-vendor';
}
if (id.includes('vue-i18n')) return 'i18n-vendor';
if (id.includes('axios')) return 'axios';
return undefined;
},
},
},
chunkSizeWarningLimit: 600,
},
resolve: {
// 避免删除 src 内过期 .js 后仍优先请求 index.js 导致 404
extensions: ['.ts', '.tsx', '.mjs', '.js', '.mts', '.jsx', '.json', '.vue'],
alias: {
// shared 的 dist 为 CommonJSVite 无法按命名导出加载;直连源码
'@thebet365/shared': resolve(__dirname, '../../packages/shared/src/index.ts'),
},
},
publicDir: resolve(__dirname, '../../packages/shared/public'),
server: {
port: 5173,
proxy: {
'/api': { target: apiTarget, changeOrigin: true },
'/uploads': { target: apiTarget, changeOrigin: true },
},
},
});