From bcd71c929694c7fe056d535ef97bdb29a87eb11f Mon Sep 17 00:00:00 2001 From: PathGao <42336971+PathGao@users.noreply.github.com> Date: Wed, 29 Jul 2026 14:01:18 +0800 Subject: [PATCH] chore(build): stop shipping production sourcemaps inside the binary (#6131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(build): stop shipping production sourcemaps inside the binary Everything under internal/web/dist is embedded into the release binary via embed.FS, and sourcemap: true put 112 .map files — 18MB, 72% of dist — inside every build users download. Nothing consumes them there: the panel never references them and npm run dev serves its own maps regardless of this flag. dist drops from 25MB to 6.7MB; flip the flag locally when a production bundle needs debugging. Co-Authored-By: Claude Fable 5 * chore(build): gate production sourcemaps behind XUI_SOURCEMAP From review: hard-coding false made the documented debugging path an edit to a tracked file, and the XUI_DEBUG serve-from-disk flow lost maps with no zero-diff way back. XUI_SOURCEMAP=true at build time restores them; the default stays off. Co-Authored-By: Claude Fable 5 --------- Co-authored-by: Claude Fable 5 --- frontend/vite.config.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index f16d215b5..1cc4906e6 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -171,7 +171,13 @@ export default defineConfig({ build: { outDir, emptyOutDir: true, - sourcemap: true, + // Everything in outDir is embedded into the Go binary via embed.FS, so + // production sourcemaps (~18MB across 112 files, 72% of dist) ship inside + // every release build. Nothing consumes them there; `npm run dev` serves + // its own maps regardless of this setting. To debug a minified bundle + // (including the XUI_DEBUG serve-from-disk path), build once with + // XUI_SOURCEMAP=true — no tracked-file edit to accidentally commit. + sourcemap: process.env.XUI_SOURCEMAP === 'true', target: 'es2020', chunkSizeWarningLimit: 1500, rollupOptions: {