@@ -8,6 +8,28 @@ import { cjsInterop } from 'vite-plugin-cjs-interop'
88import tsconfigPaths from 'vite-tsconfig-paths'
99
1010const MODE = process . env . NODE_ENV
11+ const SENTRY_UPLOAD =
12+ process . env . SENTRY_UPLOAD === 'true' || process . env . SENTRY_UPLOAD === '1'
13+
14+ if ( SENTRY_UPLOAD && MODE === 'production' ) {
15+ const authToken = process . env . SENTRY_AUTH_TOKEN
16+ const project = process . env . SENTRY_PROJECT
17+ const org = process . env . SENTRY_ORG
18+ const tokenImpliesOrg = Boolean ( authToken ?. startsWith ( 'sntrys_' ) )
19+
20+ // If upload is "on" but required settings are missing, the Sentry plugin will
21+ // skip upload but still run the delete-after-upload step, which results in
22+ // `.map` URLs returning our HTML 404 page.
23+ if ( ! authToken ) {
24+ throw new Error ( 'SENTRY_UPLOAD is enabled, but SENTRY_AUTH_TOKEN is missing' )
25+ }
26+ if ( ! project ) {
27+ throw new Error ( 'SENTRY_UPLOAD is enabled, but SENTRY_PROJECT is missing' )
28+ }
29+ if ( ! org && ! tokenImpliesOrg ) {
30+ throw new Error ( 'SENTRY_UPLOAD is enabled, but SENTRY_ORG is missing' )
31+ }
32+ }
1133
1234export default defineConfig ( async ( ) => {
1335 return {
@@ -23,7 +45,7 @@ export default defineConfig(async () => {
2345 tailwindcss ( ) ,
2446 reactRouter ( ) ,
2547 tsconfigPaths ( ) ,
26- process . env . SENTRY_UPLOAD
48+ SENTRY_UPLOAD
2749 ? sentryVitePlugin ( {
2850 disable : MODE !== 'production' ,
2951 authToken : process . env . SENTRY_AUTH_TOKEN ,
0 commit comments