Skip to content
Open
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
5 changes: 5 additions & 0 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ VITE_ESCROW_TOKEN_LABEL=XLM
# --- Monitoring Dashboard (optional) ---
# Leave empty to use bundled fixture; set to a URL to fetch live data.
# VITE_DASHBOARD_ENDPOINT=https://your-api.example.com/dashboard

# --- Build (optional) ---
# Production builds disable public source maps by default.
# For controlled debugging only, opt in to hidden source maps (not served by URL):
# WEB_BUILD_SOURCEMAP=true
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"test": "node --import tsx --test src/demo/trace-health-check.test.ts src/lib/config.test.ts src/lib/hex.test.ts src/lib/chain.test.ts src/dashboard/fixture-health-check.test.ts src/lib/round-status.test.ts src/components/dashboard/RoundStatusCard.test.tsx src/hooks/useDashboardData.test.ts src/lib/countdown.test.ts src/lib/transaction-status.test.ts src/lib/reduced-motion.test.ts src/passkey-session.test.ts && node --experimental-test-module-mocks --import tsx --test src/hooks/useRoundSession.reveal.test.tsx src/hooks/useRoundSession.refresh.test.tsx src/hooks/useLiveRound.test.tsx",
"test": "node --import tsx --test src/demo/trace-health-check.test.ts src/lib/config.test.ts src/lib/hex.test.ts src/lib/chain.test.ts src/dashboard/fixture-health-check.test.ts src/lib/round-status.test.ts src/components/dashboard/RoundStatusCard.test.tsx src/hooks/useDashboardData.test.ts src/lib/countdown.test.ts src/lib/transaction-status.test.ts src/lib/reduced-motion.test.ts src/passkey-session.test.ts src/vite-config-sourcemap.test.ts && node --experimental-test-module-mocks --import tsx --test src/hooks/useRoundSession.reveal.test.tsx src/hooks/useRoundSession.refresh.test.tsx src/hooks/useLiveRound.test.tsx",
"typecheck": "tsc --noEmit -p tsconfig.json"
},
"dependencies": {
Expand Down
22 changes: 22 additions & 0 deletions apps/web/src/vite-config-sourcemap.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2026 Sub Rosa contributors
import assert from "node:assert/strict";
import { test } from "node:test";

import { resolveBuildSourcemap } from "../vite.config";

test("production build disables public source maps by default", () => {
assert.equal(resolveBuildSourcemap("production", {}), false);
assert.equal(resolveBuildSourcemap("production", { WEB_BUILD_SOURCEMAP: "" }), false);
assert.equal(resolveBuildSourcemap("production", { WEB_BUILD_SOURCEMAP: "false" }), false);
});

test("production build allows explicit opt-in source maps for controlled debugging", () => {
assert.equal(resolveBuildSourcemap("production", { WEB_BUILD_SOURCEMAP: "true" }), "hidden");
assert.equal(resolveBuildSourcemap("production", { WEB_BUILD_SOURCEMAP: "1" }), "hidden");
assert.equal(resolveBuildSourcemap("production", { WEB_BUILD_SOURCEMAP: "hidden" }), "hidden");
});

test("development keeps source maps enabled", () => {
assert.equal(resolveBuildSourcemap("development", {}), true);
assert.equal(resolveBuildSourcemap("test", {}), true);
});
16 changes: 14 additions & 2 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ import { defineConfig } from "vite";

const require = createRequire(import.meta.url);

export default defineConfig({
export function resolveBuildSourcemap(
mode: string,
env: Record<string, string | undefined> = process.env,
): boolean | "hidden" {
if (mode !== "production") return true;
const value = env.WEB_BUILD_SOURCEMAP?.trim().toLowerCase();
return value === "true" || value === "1" || value === "hidden" ? "hidden" : false;
}

export default defineConfig(({ mode }) => ({
plugins: [
react(),
{
Expand Down Expand Up @@ -35,10 +44,13 @@ export default defineConfig({
optimizeDeps: {
include: ["buffer", "crypto-browserify", "stream-browserify", "process/browser", "events"],
},
build: {
sourcemap: resolveBuildSourcemap(mode),
},
server: {
port: 5173,
fs: {
allow: ["..", "../..", "../../..", "../../../.."],
},
},
});
}));
Loading