diff --git a/Dockerfile b/Dockerfile index 3a793bb..f01b673 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,8 @@ RUN ARCH=$(dpkg --print-architecture) \ WORKDIR /app COPY package*.json ./ +# Increase Node.js memory limit to prevent OOM during build +ENV NODE_OPTIONS=--max-old-space-size=4096 RUN npm install --ignore-scripts && npm rebuild node-pty COPY . . diff --git a/vite.config.ts b/vite.config.ts index d6359a4..9ba8292 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -37,9 +37,56 @@ export default defineConfig({ build: { outDir: '../../dist/client', emptyOutDir: true, + // Use esbuild for minification (much faster than terser) + minify: 'esbuild', + // Disable sourcemap generation for faster builds + sourcemap: false, + target: 'es2020', + // Increase chunk size warning limit (default: 500KB) + chunkSizeWarningLimit: 1000, + // CSS code splitting for better caching + cssCodeSplit: true, + rollupOptions: { + output: { + // Manual chunk splitting to speed up rendering + manualChunks(id) { + // Separate large heavy packages to avoid blocking other chunks + if (id.includes('node_modules/monaco-editor')) { + return 'monaco-editor' + } + if (id.includes('node_modules/mermaid')) { + return 'mermaid' + } + if (id.includes('node_modules/@xterm')) { + return 'xterm' + } + if (id.includes('node_modules')) { + if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) { + return 'vue-vendor' + } + if (id.includes('naive-ui')) { + return 'ui-vendor' + } + return 'vendor' + } + }, + // Optimize chunk file names for better caching + chunkFileNames: 'assets/js/[name]-[hash].js', + entryFileNames: 'assets/js/[name]-[hash].js', + assetFileNames: 'assets/[ext]/[name]-[hash].[ext]', + }, + }, }, optimizeDeps: { - include: ['monaco-editor'], + // Pre-bundle all large dependencies for faster builds + include: [ + 'monaco-editor', + 'mermaid', + 'vue', + 'vue-router', + 'pinia', + 'naive-ui', + ], }, server: { proxy: {