-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathvite.config.ts
More file actions
93 lines (89 loc) · 3.03 KB
/
vite.config.ts
File metadata and controls
93 lines (89 loc) · 3.03 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import fs from 'fs';
const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8'));
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, '.', '');
return {
base: './',
server: {
port: 3000,
host: '0.0.0.0',
},
plugins: [
react({
babel: {
plugins: [['babel-plugin-react-compiler', { target: '19' }]],
},
}),
// Sentry source maps upload (only in CI with env vars)
env.SENTRY_AUTH_TOKEN
? sentryVitePlugin({
org: env.SENTRY_ORG,
project: env.SENTRY_PROJECT,
authToken: env.SENTRY_AUTH_TOKEN,
release: {
name: packageJson.version,
},
sourcemaps: {
filesToDeleteAfterUpload: ['./dist/**/*.map'],
},
})
: null,
].filter(Boolean),
build: {
sourcemap: true,
rollupOptions: {
external: [
'electron',
'fluent-ffmpeg',
'ffmpeg-static',
'ffprobe-static',
'electron-squirrel-startup',
'path',
'fs',
'child_process',
],
output: {
manualChunks: {
// React core
'vendor-react': ['react', 'react-dom'],
// UI components & virtualization
'vendor-ui': ['react-virtuoso', 'lucide-react', 'react-colorful', 'react-rnd', 'assjs'],
// Internationalization
'vendor-i18n': ['i18next', 'react-i18next', 'i18next-browser-languagedetector'],
// AI SDKs
'vendor-ai': ['@google/genai', 'openai', '@anthropic-ai/sdk'],
// State & utilities
'vendor-utils': ['zustand', 'clsx', 'tailwind-merge', 'uuid', 'jsonrepair', 'p-map'],
// JSON viewer (large component, rarely used)
'vendor-json': ['@uiw/react-json-view'],
},
},
},
},
define: {
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY),
'process.env.OPENAI_API_KEY': JSON.stringify(env.OPENAI_API_KEY),
__APP_VERSION__: JSON.stringify(packageJson.version),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@components': path.resolve(__dirname, './src/components'),
'@services': path.resolve(__dirname, './src/services'),
'@hooks': path.resolve(__dirname, './src/hooks'),
'@utils': path.resolve(__dirname, './src/utils'),
'@types': path.resolve(__dirname, './src/types'),
'@constants': path.resolve(__dirname, './src/constants'),
'@electron': path.resolve(__dirname, './electron'),
},
},
};
});