chore(build): stop shipping production sourcemaps inside the binary (#6131)

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
PathGao
2026-07-29 14:01:18 +08:00
committed by GitHub
parent 33f72f8f4a
commit bcd71c9296

View File

@@ -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: {