Files
hermes-ui/vite.config.ts
T
toor 1e9ea89d86
Build / build (push) Canceled after 0s
NPM Lockfile Check / npm ci --ignore-scripts (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
chore: bootstrap hermes-ui skeleton from 0.6.29 snapshot
Import the client, server, skills, tests, and build scripts as the starting
point for the rebuild, then trim the surfaces this project does not ship:
Electron desktop packaging, the marketing website, and the ESP32 firmware
tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows.

Rename the package and CLI entry points to hermes-ui, drop the prepare hook so
npm ci no longer triggers a build, and drop the removed tsconfig and nodemon
references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs
so the documented package map and hard rules match this repository.

reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
2026-10-16 10:34:35 +08:00

114 lines
3.1 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 FRONTEND_PORT = Number(process.env.HERMES_WEB_UI_FRONTEND_PORT || 8649)
const BACKEND_PORT = process.env.HERMES_WEB_UI_BACKEND_PORT || '8648'
const BACKEND = `http://127.0.0.1:${BACKEND_PORT}`
function createProxyConfig(): ProxyOptions {
return {
target: BACKEND,
changeOrigin: true,
ws: true,
configure: (proxy) => {
proxy.on('proxyReq', (proxyReq) => {
proxyReq.removeHeader('origin')
proxyReq.removeHeader('referer')
})
proxy.on('proxyReqWs', (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: {
port: FRONTEND_PORT,
strictPort: true,
proxy: {
'/api': createProxyConfig(),
'/v1': createProxyConfig(),
'/health': createProxyConfig(),
'/upload': createProxyConfig(),
'/webhook': createProxyConfig(),
'/socket.io': {
target: BACKEND,
ws: true,
},
},
},
})