mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-25 13:30:14 +00:00
0011d76ddb
Major optimizations to resolve Docker build hanging at "rendering chunks..." phase: **Vite Configuration (vite.config.ts)**: - Switch minifier from terser to esbuild (10-100x faster) - Disable sourcemap generation to reduce build time - Implement aggressive chunk splitting for large dependencies: - monaco-editor (73MB) → separate chunk - mermaid (75MB) → separate chunk - @xterm (6.1MB) → separate chunk - vue-vendor, ui-vendor, vendor → logical groupings - Enable CSS code splitting for better caching - Increase chunk size warning limit to 1000KB - Pre-bundle large dependencies (monaco-editor, mermaid, vue, pinia, naive-ui) **Dockerfile Changes**: - Add NODE_OPTIONS=--max-old-space-size=4096 to prevent OOM during build - Move NODE_ENV=production before build step for consistency **Root Cause Analysis**: The build bottleneck was caused by three massive dependencies totaling ~150MB: - monaco-editor (73MB) - VS Code editor for file editing - mermaid (75MB) - Diagram rendering in chat messages - @xterm (6.1MB) - Web terminal These packages caused vite:asset (43%) and vite:terser (8%) phases to take excessive time, especially in resource-constrained Docker environments. **Expected Impact**: - 50-70% faster build times (primarily from esbuild + pre-bundling) - Eliminate hanging at "rendering chunks..." phase - Better memory management during Docker builds Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
105 lines
2.8 KiB
TypeScript
105 lines
2.8 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import type { ProxyOptions } from 'vite'
|
|
import { resolve } from 'path'
|
|
import pkg from './package.json'
|
|
|
|
const BACKEND = 'http://127.0.0.1:8648'
|
|
|
|
function createProxyConfig(): ProxyOptions {
|
|
return {
|
|
target: BACKEND,
|
|
changeOrigin: true,
|
|
configure: (proxy) => {
|
|
proxy.on('proxyReq', (proxyReq) => {
|
|
proxyReq.removeHeader('origin')
|
|
proxyReq.removeHeader('referer')
|
|
})
|
|
proxy.on('proxyRes', (proxyRes) => {
|
|
proxyRes.headers['cache-control'] = 'no-cache'
|
|
proxyRes.headers['x-accel-buffering'] = 'no'
|
|
})
|
|
},
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
root: 'packages/client',
|
|
plugins: [vue()],
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, 'packages/client/src'),
|
|
},
|
|
},
|
|
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: {
|
|
// Pre-bundle all large dependencies for faster builds
|
|
include: [
|
|
'monaco-editor',
|
|
'mermaid',
|
|
'vue',
|
|
'vue-router',
|
|
'pinia',
|
|
'naive-ui',
|
|
],
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api': createProxyConfig(),
|
|
'/v1': createProxyConfig(),
|
|
'/health': createProxyConfig(),
|
|
'/upload': createProxyConfig(),
|
|
'/webhook': createProxyConfig(),
|
|
'/socket.io': {
|
|
target: BACKEND,
|
|
ws: true,
|
|
},
|
|
},
|
|
},
|
|
})
|