Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage": "https://do0ori.github.io/visual-timer",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "tsc && vite build && node scripts/strip-sourcemaps.mjs",
"test": "jest --runInBand",
"preview": "vite preview",
"format": "prettier . --write"
Expand Down
17 changes: 17 additions & 0 deletions scripts/strip-sourcemaps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Runs after `vite build`, which builds the app and then — in vite-plugin-pwa's
// own pass, past every plugin hook — the service worker. Source maps only exist
// so the Sentry plugin can upload them during that build; none may be published
// to GitHub Pages, so drop whatever is left.
import { readdirSync, rmSync } from 'node:fs';
import { join } from 'node:path';

const DIST = 'dist';

const removed = readdirSync(DIST, { recursive: true, encoding: 'utf-8' })
.filter((entry) => entry.endsWith('.map'))
.map((entry) => {
rmSync(join(DIST, entry));
return entry;
});

console.log(removed.length ? `Stripped source maps: ${removed.join(', ')}` : 'No source maps to strip.');
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default defineConfig({
}),
],
build: {
// Generated only when they can be uploaded to Sentry, and deleted from dist
// afterwards, so source maps are never published to GitHub Pages.
// Generated only when they can be uploaded to Sentry. `strip-sourcemaps`
// clears the leftovers afterwards, so none are published to GitHub Pages.
sourcemap: uploadSourcemaps ? 'hidden' : false,
},
server: {
Expand Down
Loading