-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
71 lines (69 loc) · 1.91 KB
/
vite.config.ts
File metadata and controls
71 lines (69 loc) · 1.91 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import electron from 'vite-plugin-electron'
import electronRenderer from 'vite-plugin-electron-renderer'
export default defineConfig(({ command }) => {
const isServe = command === 'serve'
const isBuild = command === 'build'
const isElectron = process.env.ELECTRON === 'true'
return {
server: {
port: 3001,
},
plugins: [
react(),
tailwindcss(),
// Only include Electron plugins when building for Electron
...(isElectron ? [
electron([
{
// Main process entry point
entry: 'electron/main.ts',
onstart({ startup }) {
if (isServe) {
startup()
}
},
vite: {
build: {
sourcemap: isServe,
minify: isBuild,
outDir: 'dist-electron',
rollupOptions: {
// active-win is a native module that must not be bundled
external: ['electron', 'active-win'],
},
},
},
},
{
// Preload script entry point
entry: 'electron/preload.ts',
onstart({ reload }) {
if (isServe) {
reload()
}
},
vite: {
build: {
sourcemap: isServe ? 'inline' : undefined,
minify: isBuild,
outDir: 'dist-electron',
rollupOptions: {
external: ['electron'],
output: {
format: 'cjs',
},
},
},
},
},
]),
electronRenderer(),
] : []),
],
// Clear screen only in development
clearScreen: false,
}
})