From 7d163e833894add41f4da0502b58c0eb3407c14a Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Thu, 26 Nov 2026 11:10:00 +0800 Subject: [PATCH] chore(build): add a modern-only frontend build without legacy @vitejs/plugin-legacy rebuilds and Babel-transpiles the whole app for a nomodule fallback the Chrome 81 baseline never uses, and it dominates build time and memory. Gate it behind SQLBOT_LEGACY and add a build:modern script so routine builds can skip it. Co-Authored-By: Claude Sonnet 5 --- frontend/package.json | 1 + frontend/vite.config.ts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 74721ee1a..50156e286 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,6 +12,7 @@ "scripts": { "dev": "vue-tsc -b && vite", "build": "vue-tsc -b &&NODE_OPTIONS=--max_old_space_size=4096 vite build", + "build:modern": "vue-tsc -b && SQLBOT_LEGACY=false NODE_OPTIONS=--max_old_space_size=4096 vite build", "preview": "vite preview", "lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx --fix" }, diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index e76a9a97d..30c6b3ffc 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -9,6 +9,9 @@ import legacy from '@vitejs/plugin-legacy' export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd()) + // Opt out with SQLBOT_LEGACY=false (npm run build:modern) to skip the + // duplicate Babel/legacy bundle, which dominates build time and memory. + const withLegacy = process.env.SQLBOT_LEGACY !== 'false' console.info(mode) console.info(env) return { @@ -28,11 +31,15 @@ export default defineConfig(({ mode }) => { svgo: false, defaultImport: 'component', // or 'raw' }), - legacy({ - targets: ['Chrome >= 81'], - polyfills: true, - modernPolyfills: true, - }), + ...(withLegacy + ? [ + legacy({ + targets: ['Chrome >= 81'], + polyfills: true, + modernPolyfills: true, + }), + ] + : []), ], resolve: { alias: {