Repository navigation
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
56 lines (53 loc) · 1.66 KB
/
Copy pathelectron.vite.config.ts
File metadata and controls
56 lines (53 loc) · 1.66 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
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { resolve } from 'path'
import { execSync } from 'child_process'
import { readFileSync } from 'fs'
// Version surfaces show the build hash so a bug report identifies an exact
// commit. Resolve it at build time because the packaged app has no .git.
function buildHash(): string {
try {
return execSync('git rev-parse --short HEAD', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || 'dev'
} catch {
return 'dev'
}
}
const appVersion = JSON.parse(readFileSync(resolve('package.json'), 'utf8')).version as string
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
define: {
__APP_VERSION__: JSON.stringify(appVersion),
__BUILD_HASH__: JSON.stringify(buildHash()),
},
build: {
rollupOptions: {
external: ['fsevents'],
input: {
index: resolve('src/main/index.ts'),
headless: resolve('src/main/headless.ts'),
hub: resolve('src/main/hub.ts'),
brain: resolve('src/main/hub-machine-enrollment.ts'),
},
},
}
},
preload: {
plugins: [externalizeDepsPlugin()],
build: { rollupOptions: { external: ['fsevents'] } }
},
renderer: {
// The in-app browser tab needs to reach local dev servers too; binding the
// renderer to all interfaces avoids localhost/127.0.0.1/::1 mismatches.
server: {
host: '0.0.0.0',
},
resolve: {
alias: {
'@renderer': resolve('src/renderer/src')
}
},
plugins: [react(), tailwindcss()]
}
})