-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathplugin.ts
26 lines (23 loc) · 972 Bytes
/
plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { ConfigEnv } from 'vite';
import { type Plugin } from 'vite';
import { makeCustomSentryVitePlugins } from './makeCustomSentryVitePlugins';
import { makeEnableSourceMapsPlugin } from './makeEnableSourceMapsPlugin';
import type { SentryReactRouterBuildOptions } from './types';
/**
* A Vite plugin for Sentry that handles source map uploads and bundle size optimizations.
*
* @param options - Configuration options for the Sentry Vite plugin
* @param viteConfig - The Vite user config object
* @returns An array of Vite plugins
*/
export async function sentryReactRouter(
options: SentryReactRouterBuildOptions = {},
config: ConfigEnv,
): Promise<Plugin[]> {
const plugins: Plugin[] = [];
if (process.env.NODE_ENV !== 'development' && config.command === 'build' && config.mode !== 'development') {
plugins.push(makeEnableSourceMapsPlugin(options));
plugins.push(...(await makeCustomSentryVitePlugins(options)));
}
return plugins;
}