File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
packages/react-router/src/vite Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 11export { sentryReactRouter } from './plugin' ;
22export { sentryOnBuildEnd } from './buildEnd/handleOnBuildEnd' ;
33export type { SentryReactRouterBuildOptions } from './types' ;
4+ export { makeConfigInjectorPlugin } from './makeConfigInjectorPlugin' ;
Original file line number Diff line number Diff line change 1+ import { type Plugin } from 'vite' ;
2+ import type { SentryReactRouterBuildOptions } from './types' ;
3+
4+ /**
5+ * Creates a Vite plugin that injects the Sentry options into the global Vite config.
6+ * This ensures the sentryConfig is available to other components that need access to it,
7+ * like the buildEnd hook.
8+ *
9+ * @param options - Configuration options for the Sentry Vite plugin
10+ * @returns A Vite plugin that injects sentryConfig into the global config
11+ */
12+ export function makeConfigInjectorPlugin ( options : SentryReactRouterBuildOptions ) : Plugin {
13+ return {
14+ name : 'sentry-react-router-config-injector' ,
15+ enforce : 'pre' ,
16+ config ( config ) {
17+ return {
18+ ...config ,
19+ sentryConfig : options ,
20+ } ;
21+ } ,
22+ } ;
23+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { type Plugin } from 'vite';
33import { makeCustomSentryVitePlugins } from './makeCustomSentryVitePlugins' ;
44import { makeEnableSourceMapsPlugin } from './makeEnableSourceMapsPlugin' ;
55import type { SentryReactRouterBuildOptions } from './types' ;
6+ import { makeConfigInjectorPlugin } from './makeConfigInjectorPlugin' ;
67
78/**
89 * A Vite plugin for Sentry that handles source map uploads and bundle size optimizations.
@@ -17,6 +18,8 @@ export async function sentryReactRouter(
1718) : Promise < Plugin [ ] > {
1819 const plugins : Plugin [ ] = [ ] ;
1920
21+ plugins . push ( makeConfigInjectorPlugin ( options ) ) ;
22+
2023 if ( process . env . NODE_ENV !== 'development' && config . command === 'build' && config . mode !== 'development' ) {
2124 plugins . push ( makeEnableSourceMapsPlugin ( options ) ) ;
2225 plugins . push ( ...( await makeCustomSentryVitePlugins ( options ) ) ) ;
You can’t perform that action at this time.
0 commit comments