-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathmakeCustomSentryVitePlugins.ts
More file actions
63 lines (60 loc) · 1.96 KB
/
makeCustomSentryVitePlugins.ts
File metadata and controls
63 lines (60 loc) · 1.96 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { sentryVitePlugin } from '@sentry/vite-plugin';
import { type Plugin } from 'vite';
import type { SentryReactRouterBuildOptions } from './types';
/**
* Create a custom subset of sentry's vite plugins
*/
export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuildOptions): Promise<Plugin[]> {
const {
debug,
unstable_sentryVitePluginOptions,
bundleSizeOptimizations,
authToken,
org,
project,
telemetry,
reactComponentAnnotation,
release,
} = options;
const sentryVitePlugins = sentryVitePlugin({
authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,
bundleSizeOptimizations,
debug: debug ?? false,
org: org ?? process.env.SENTRY_ORG,
project: project ?? process.env.SENTRY_PROJECT,
telemetry: telemetry ?? true,
_metaOptions: {
telemetry: {
metaFramework: 'react-router',
},
...unstable_sentryVitePluginOptions?._metaOptions,
},
reactComponentAnnotation: {
enabled: reactComponentAnnotation?.enabled ?? undefined,
ignoredComponents: reactComponentAnnotation?.ignoredComponents ?? undefined,
...unstable_sentryVitePluginOptions?.reactComponentAnnotation,
},
release: {
...unstable_sentryVitePluginOptions?.release,
...release,
},
// will be handled in buildEnd hook
sourcemaps: {
disable: true,
...unstable_sentryVitePluginOptions?.sourcemaps,
},
...unstable_sentryVitePluginOptions,
}) as Plugin[];
// only use a subset of the plugins as all upload and file deletion tasks will be handled in the buildEnd hook
return [
...sentryVitePlugins.filter(plugin => {
return [
'sentry-telemetry-plugin',
'sentry-vite-injection-plugin',
...(reactComponentAnnotation?.enabled || unstable_sentryVitePluginOptions?.reactComponentAnnotation?.enabled
? ['sentry-vite-component-name-annotate-plugin']
: []),
].includes(plugin.name);
}),
];
}