-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
49 lines (41 loc) · 1.28 KB
/
vite.config.ts
File metadata and controls
49 lines (41 loc) · 1.28 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
import { defineConfig, loadEnv, PluginOption } from 'vite'
import react from '@vitejs/plugin-react'
import svgr from "vite-plugin-svgr";
import { sentryVitePlugin } from '@sentry/vite-plugin';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, process.cwd(), '');
const plugins: PluginOption[] = [
react(),
svgr(),
];
// Add Sentry plugin for source maps upload (only in production)
if (mode === 'production' && env.VITE_SENTRY_DSN) {
plugins.push(sentryVitePlugin({
org: env.SENTRY_ORG,
project: env.SENTRY_PROJECT,
authToken: env.SENTRY_AUTH_TOKEN,
// Upload source maps to Sentry
sourcemaps: {
assets: './build/assets/**',
filesToDeleteAfterUpload: './build/assets/**/*.map',
},
// Other options
telemetry: false,
}));
}
return {
plugins,
build: {
outDir: './build',
emptyOutDir: true,
// Generate source maps for production (hidden from public)
sourcemap: 'hidden',
},
// Define global constants
define: {
'import.meta.env.VITE_APP_VERSION': JSON.stringify(process.env.npm_package_version),
},
};
})