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 1
1
export { sentryReactRouter } from './plugin' ;
2
2
export { sentryOnBuildEnd } from './buildEnd/handleOnBuildEnd' ;
3
3
export 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';
3
3
import { makeCustomSentryVitePlugins } from './makeCustomSentryVitePlugins' ;
4
4
import { makeEnableSourceMapsPlugin } from './makeEnableSourceMapsPlugin' ;
5
5
import type { SentryReactRouterBuildOptions } from './types' ;
6
+ import { makeConfigInjectorPlugin } from './makeConfigInjectorPlugin' ;
6
7
7
8
/**
8
9
* A Vite plugin for Sentry that handles source map uploads and bundle size optimizations.
@@ -17,6 +18,8 @@ export async function sentryReactRouter(
17
18
) : Promise < Plugin [ ] > {
18
19
const plugins : Plugin [ ] = [ ] ;
19
20
21
+ plugins . push ( makeConfigInjectorPlugin ( options ) ) ;
22
+
20
23
if ( process . env . NODE_ENV !== 'development' && config . command === 'build' && config . mode !== 'development' ) {
21
24
plugins . push ( makeEnableSourceMapsPlugin ( options ) ) ;
22
25
plugins . push ( ...( await makeCustomSentryVitePlugins ( options ) ) ) ;
You can’t perform that action at this time.
0 commit comments