-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathvite.renderer.config.mts
More file actions
62 lines (60 loc) · 2.09 KB
/
vite.renderer.config.mts
File metadata and controls
62 lines (60 loc) · 2.09 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
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { tanstackRouter } from '@tanstack/router-plugin/vite';
import path from 'path';
import { codeInspectorPlugin } from 'code-inspector-plugin';
import { sentryVitePlugin } from '@sentry/vite-plugin';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN || env.SENTRY_AUTH_TOKEN;
const shouldEnableSentry = mode === 'production' && Boolean(sentryAuthToken);
return {
plugins: [
...(shouldEnableSentry
? [
sentryVitePlugin({
org: process.env.SENTRY_ORG || env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT || env.SENTRY_PROJECT,
authToken: sentryAuthToken,
release: {
name: `${process.env.npm_package_name}@${process.env.npm_package_version}`,
},
// Electron loads files from app://, so we need to normalize paths for Source Map matching
sourcemaps: {
// Rewrite the source paths to strip the Electron app:// protocol
rewriteSources: (source) => {
// Transform: app:///.vite/renderer/main_window/assets/index.js
// Into: ~/.vite/renderer/main_window/assets/index.js
return source.replace(/^app:\/\/\//, '~/');
},
},
}),
]
: []),
tanstackRouter({
target: 'react',
autoCodeSplitting: true,
}),
tailwindcss(),
react({
babel: {
plugins: ['babel-plugin-react-compiler'],
},
}),
codeInspectorPlugin({ bundler: 'vite' }),
],
optimizeDeps: {
entries: ['index.html'],
},
define: {
'process.env.SENTRY_DSN': JSON.stringify(process.env.SENTRY_DSN || env.SENTRY_DSN),
},
resolve: {
preserveSymlinks: true,
alias: {
'@': path.resolve(process.cwd(), './src'),
},
},
};
});