diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 38770704..e02b716d 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -48,64 +48,22 @@ export default defineConfig(({ mode }) => { }), injectPublicSettings(backendUrl) ], - resolve: { - alias: { - '@': resolve(__dirname, 'src'), - // 使用 vue-i18n 运行时版本,避免 CSP unsafe-eval 问题 - 'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js' - } - }, - define: { - // 启用 vue-i18n JIT 编译,在 CSP 环境下处理消息插值 - // JIT 编译器生成 AST 对象而非 JS 代码,无需 unsafe-eval - __INTLIFY_JIT_COMPILATION__: true - }, - build: { - outDir: '../backend/internal/web/dist', - emptyOutDir: true, - rollupOptions: { - output: { - /** - * 手动分包配置 - * 分离第三方库并按功能合并应用代码,避免循环依赖 - */ - manualChunks(id: string) { - if (id.includes('node_modules')) { - // Vue 核心库 - if ( - id.includes('/vue/') || - id.includes('/vue-router/') || - id.includes('/pinia/') || - id.includes('/@vue/') - ) { - return 'vendor-vue' - } - - // UI 工具库(较大,单独分离) - if (id.includes('/@vueuse/') || id.includes('/xlsx/')) { - return 'vendor-ui' - } - - // 图表库 - if (id.includes('/chart.js/') || id.includes('/vue-chartjs/')) { - return 'vendor-chart' - } - - // 国际化 - if (id.includes('/vue-i18n/') || id.includes('/@intlify/')) { - return 'vendor-i18n' - } - - // 其他小型第三方库合并 - return 'vendor-misc' - } - - // 应用代码:按入口点自动分包,不手动干预 - // 这样可以避免循环依赖,同时保持合理的 chunk 数量 - } + resolve: { + alias: { + '@': resolve(__dirname, 'src'), + // 使用 vue-i18n 运行时版本,避免 CSP unsafe-eval 问题 + 'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js' } - } - }, + }, + define: { + // 启用 vue-i18n JIT 编译,在 CSP 环境下处理消息插值 + // JIT 编译器生成 AST 对象而非 JS 代码,无需 unsafe-eval + __INTLIFY_JIT_COMPILATION__: true + }, + build: { + outDir: '../backend/internal/web/dist', + emptyOutDir: true + }, server: { host: '0.0.0.0', port: devPort,