-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
64 lines (61 loc) · 1.79 KB
/
vite.config.ts
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
import path from 'path'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import electron from 'vite-plugin-electron'
import fs from 'fs'
const SRC_DIR = path.resolve(__dirname, './src')
const PUBLIC_DIR = path.resolve(__dirname, './public')
const BUILD_DIR = path.resolve(__dirname, './dist')
const ELECTRON_DIR = path.resolve(__dirname, './electron')
export default async () => {
let electronModules = await fs.promises.readdir(ELECTRON_DIR)
electronModules = electronModules.filter((file) => file !== 'main.js')
const generateInput = (files) => {
const res = {}
for (const file of files) {
const [name, _] = file.split('.')
res[name] = path.join(ELECTRON_DIR, file)
}
return res
}
return {
plugins: [
react(),
tsconfigPaths(),
electron({
entry: path.join(ELECTRON_DIR, 'main.js'),
vite: {
build: {
lib: {
entry: electronModules.map((file) =>
path.join(ELECTRON_DIR, file)
),
},
},
},
// onstart: (args) => {
// args.startup()
// },
}),
],
root: SRC_DIR,
base: '',
publicDir: PUBLIC_DIR,
build: {
outDir: BUILD_DIR,
assetsInlineLimit: 0,
emptyOutDir: true,
rollupOptions: {
treeshake: false,
},
},
resolve: {
alias: {
'@': SRC_DIR,
},
},
server: {
host: true,
},
}
}