feat: upload browser source maps to GlitchTip at build time #33

Merged
ronnyandre merged 1 commit from feat/glitchtip-sourcemaps into main 2026-11-17 13:24:33 +01:00
Owner

What

Browser errors in GlitchTip currently show minified stack frames. This uploads client source maps on every pnpm build so frames resolve to the original source.

  • Client build emits hidden source maps (no sourceMappingURL comment).
  • New Vite plugin glitchtipSourcemaps() (scripts/glitchtip-sourcemaps.ts) runs after the client bundle is written:
    1. If GLITCHTIP_AUTH_TOKEN, GLITCHTIP_ORG and GLITCHTIP_PROJECT are set, runs @sentry/cli sourcemaps inject and upload. Debug IDs tie each chunk to its map, so no release has to match. GLITCHTIP_URL defaults to the origin of GLITCHTIP_DSN.
    2. Always deletes the .map files, so the source is never served.
  • A failed upload only warns, so a deploy is never blocked.
  • It's a Vite plugin rather than a post-build script because Nitro builds its static-asset manifest after the client build. Maps deleted later would 500 instead of 404.
  • @sentry/cli (2.x) is a devDependency. Its postinstall is disabled in allowBuilds, because the binary ships as a per-platform optional dependency.

Deploy

Set GLITCHTIP_AUTH_TOKEN (project:releases scope), GLITCHTIP_ORG and GLITCHTIP_PROJECT as build-time env vars in Dokploy. Without them the upload is skipped, and the maps are still removed.

Checks

pnpm typecheck, pnpm lint and pnpm build pass locally. The upload was skipped locally (no credentials), the plugin removed 38 .map files, and .output/ contains none. The actual upload to GlitchTip is untested until a deploy has the env vars set.

🤖 Generated with Claude Code

## What Browser errors in GlitchTip currently show minified stack frames. This uploads client source maps on every `pnpm build` so frames resolve to the original source. - Client build emits `hidden` source maps (no `sourceMappingURL` comment). - New Vite plugin `glitchtipSourcemaps()` (`scripts/glitchtip-sourcemaps.ts`) runs after the client bundle is written: 1. If `GLITCHTIP_AUTH_TOKEN`, `GLITCHTIP_ORG` and `GLITCHTIP_PROJECT` are set, runs `@sentry/cli sourcemaps inject` and `upload`. Debug IDs tie each chunk to its map, so no release has to match. `GLITCHTIP_URL` defaults to the origin of `GLITCHTIP_DSN`. 2. **Always** deletes the `.map` files, so the source is never served. - A failed upload only warns, so a deploy is never blocked. - It's a Vite plugin rather than a post-build script because Nitro builds its static-asset manifest after the client build. Maps deleted later would 500 instead of 404. - `@sentry/cli` (2.x) is a devDependency. Its postinstall is disabled in `allowBuilds`, because the binary ships as a per-platform optional dependency. ## Deploy Set `GLITCHTIP_AUTH_TOKEN` (`project:releases` scope), `GLITCHTIP_ORG` and `GLITCHTIP_PROJECT` as **build-time** env vars in Dokploy. Without them the upload is skipped, and the maps are still removed. ## Checks `pnpm typecheck`, `pnpm lint` and `pnpm build` pass locally. The upload was skipped locally (no credentials), the plugin removed 38 `.map` files, and `.output/` contains none. The actual upload to GlitchTip is untested until a deploy has the env vars set. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The client build now emits hidden source maps. A Vite plugin runs after
the client bundle is written: when GLITCHTIP_AUTH_TOKEN/ORG/PROJECT are
set it injects debug IDs and uploads the maps with @sentry/cli, then
always deletes the .map files so source is never served. A failed upload
only warns. It runs as a plugin (not a post-build script) so the maps are
gone before Nitro builds its static-asset manifest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!33
No description provided.