-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
115 lines (111 loc) · 2.71 KB
/
electron.vite.config.ts
File metadata and controls
115 lines (111 loc) · 2.71 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { execSync } from 'node:child_process';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import react from '@vitejs/plugin-react-swc';
import { defineConfig } from 'electron-vite';
import path from 'path';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { version } from './package.json';
function getRelease(): string {
try {
const sha = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
return `${version}-${sha}`;
} catch {
return version;
}
}
const release = getRelease();
const sentryPlugin = () =>
sentryVitePlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
url: process.env.SENTRY_URL,
release: {
name: release,
},
silent: !process.env.CI,
});
export default defineConfig({
main: {
define: {
__SENTRY_RELEASE__: JSON.stringify(release),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
sourcemap: true,
externalizeDeps: {
exclude: ['got'],
},
rollupOptions: {
input: {
index: path.resolve(__dirname, 'src/main/index.ts'),
'db-worker': path.resolve(__dirname, 'src/main/db/db-worker.ts'),
},
external: ['better-sqlite3'],
},
},
plugins: [sentryPlugin()],
},
preload: {
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
sourcemap: true,
rollupOptions: {
input: {
index: path.resolve(__dirname, 'src/preload/index.ts'),
},
},
},
plugins: [sentryPlugin()],
},
renderer: {
define: {
__SENTRY_RELEASE__: JSON.stringify(release),
},
root: 'src/renderer',
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@resources': path.resolve(__dirname, './resources'),
'@renderer': path.resolve(__dirname, './src/renderer'),
'@components': path.resolve(__dirname, './src/renderer/components'),
'@store': path.resolve(__dirname, './src/renderer/store'),
},
},
plugins: [
react(),
nodePolyfills({
include: ['path', 'stream', 'crypto', 'buffer', 'process'],
globals: {
Buffer: true,
global: true,
process: true,
},
}),
sentryPlugin(),
],
build: {
sourcemap: true,
outDir: path.resolve(__dirname, 'out/renderer'),
rollupOptions: {
input: {
index: path.resolve(__dirname, 'src/renderer/index.html'),
},
},
},
server: {
port: 5173,
hmr: {
overlay: true,
},
},
},
});