-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
76 lines (74 loc) · 1.78 KB
/
vite.config.ts
File metadata and controls
76 lines (74 loc) · 1.78 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import electron from 'vite-plugin-electron'
import renderer from 'vite-plugin-electron-renderer'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
import { readFileSync } from 'fs'
const __dirname = dirname(fileURLToPath(import.meta.url))
const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8'))
export default defineConfig({
plugins: [
react(),
electron([
{
entry: 'electron/main.ts',
vite: {
build: {
outDir: 'dist-electron',
lib: {
entry: 'electron/main.ts',
formats: ['cjs']
},
rollupOptions: {
external: ['electron', 'better-sqlite3', 'tar'],
output: {
format: 'cjs',
entryFileNames: '[name].js'
}
}
}
}
},
{
entry: 'electron/preload.ts',
onstart(options) {
options.reload()
},
vite: {
build: {
outDir: 'dist-electron',
lib: {
entry: 'electron/preload.ts',
formats: ['cjs']
},
rollupOptions: {
external: ['electron'],
output: {
format: 'cjs',
entryFileNames: '[name].js'
}
}
}
}
}
]),
renderer()
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'@shared': resolve(__dirname, 'src/shared')
}
},
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html')
}
}
},
define: {
__APP_VERSION__: JSON.stringify(pkg.version)
}
})