11import { reactRouter } from '@react-router/dev/vite'
2- import { sentryVitePlugin } from '@sentry/vite-plugin'
3-
2+ import {
3+ sentryReactRouter ,
4+ type SentryReactRouterBuildOptions ,
5+ } from '@sentry/react-router'
6+ import { defineConfig } from 'vite'
47import { envOnlyMacros } from 'vite-env-only'
5- import { type ViteUserConfig } from 'vitest/config'
68
79const MODE = process . env . NODE_ENV
810
9- export default {
11+ export default defineConfig ( ( config ) => ( {
1012 build : {
1113 target : 'es2022' ,
1214 cssMinify : MODE === 'production' ,
@@ -32,30 +34,14 @@ export default {
3234 ignored : [ '**/playwright-report/**' ] ,
3335 } ,
3436 } ,
37+ sentryConfig,
3538 plugins : [
3639 envOnlyMacros ( ) ,
3740 // it would be really nice to have this enabled in tests, but we'll have to
3841 // wait until https://github.com/remix-run/remix/issues/9871 is fixed
39- process . env . NODE_ENV === 'test' ? null : reactRouter ( ) ,
40- process . env . SENTRY_AUTH_TOKEN
41- ? sentryVitePlugin ( {
42- disable : MODE !== 'production' ,
43- authToken : process . env . SENTRY_AUTH_TOKEN ,
44- org : process . env . SENTRY_ORG ,
45- project : process . env . SENTRY_PROJECT ,
46- release : {
47- name : process . env . COMMIT_SHA ,
48- setCommits : {
49- auto : true ,
50- } ,
51- } ,
52- sourcemaps : {
53- filesToDeleteAfterUpload : [
54- './build/**/*.map' ,
55- '.server-build/**/*.map' ,
56- ] ,
57- } ,
58- } )
42+ MODE === 'test' ? null : reactRouter ( ) ,
43+ MODE === 'production' && process . env . SENTRY_AUTH_TOKEN
44+ ? sentryReactRouter ( sentryConfig , config )
5945 : null ,
6046 ] ,
6147 test : {
@@ -68,4 +54,22 @@ export default {
6854 all : true ,
6955 } ,
7056 } ,
71- } satisfies ViteUserConfig
57+ } ) )
58+
59+ const sentryConfig : SentryReactRouterBuildOptions = {
60+ authToken : process . env . SENTRY_AUTH_TOKEN ,
61+ org : process . env . SENTRY_ORG ,
62+ project : process . env . SENTRY_PROJECT ,
63+
64+ unstable_sentryVitePluginOptions : {
65+ release : {
66+ name : process . env . COMMIT_SHA ,
67+ setCommits : {
68+ auto : true ,
69+ } ,
70+ } ,
71+ sourcemaps : {
72+ filesToDeleteAfterUpload : [ './build/**/*.map' , '.server-build/**/*.map' ] ,
73+ } ,
74+ } ,
75+ }
0 commit comments