|
1 | 1 | import { reactRouter } from '@react-router/dev/vite'; |
| 2 | +import { |
| 3 | + type SentryReactRouterBuildOptions, |
| 4 | + sentryReactRouter, |
| 5 | +} from '@sentry/react-router'; |
2 | 6 | import svgr from '@svgr/rollup'; |
3 | 7 | import tailwindcss from '@tailwindcss/vite'; |
4 | 8 | import { visualizer } from 'rollup-plugin-visualizer'; |
5 | | -import { type PluginOption, defineConfig } from 'vite'; |
| 9 | +import { type PluginOption, defineConfig, loadEnv } from 'vite'; |
6 | 10 | import tsconfigPaths from 'vite-tsconfig-paths'; |
7 | 11 |
|
8 | | -export default defineConfig({ |
9 | | - plugins: [ |
10 | | - svgr(), |
11 | | - tailwindcss(), |
12 | | - reactRouter(), |
13 | | - tsconfigPaths(), |
14 | | - visualizer() as PluginOption, |
15 | | - ], |
16 | | - optimizeDeps: { |
17 | | - exclude: ['@amcharts/amcharts5'], |
18 | | - }, |
19 | | - build: { |
20 | | - rollupOptions: { |
21 | | - external: ['d3-geo,d3-selection,d3-transition'], |
| 12 | +export default defineConfig((config) => { |
| 13 | + const env = loadEnv(config.mode, process.cwd()); |
| 14 | + const sentryConfig: SentryReactRouterBuildOptions = { |
| 15 | + org: env.VITE_SENTRY_ORG, |
| 16 | + project: env.VITE_SENTRY_PROJECT, |
| 17 | + authToken: env.VITE_SENTRY_AUTH_TOKEN, |
| 18 | + }; |
| 19 | + |
| 20 | + return { |
| 21 | + plugins: [ |
| 22 | + svgr(), |
| 23 | + tailwindcss(), |
| 24 | + reactRouter(), |
| 25 | + tsconfigPaths(), |
| 26 | + visualizer() as PluginOption, |
| 27 | + sentryReactRouter(sentryConfig, config), |
| 28 | + ], |
| 29 | + optimizeDeps: { |
| 30 | + exclude: ['@amcharts/amcharts5'], |
| 31 | + }, |
| 32 | + build: { |
| 33 | + rollupOptions: { |
| 34 | + external: ['d3-geo,d3-selection,d3-transition'], |
| 35 | + }, |
22 | 36 | }, |
23 | | - }, |
| 37 | + }; |
24 | 38 | }); |
0 commit comments