-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
73 lines (70 loc) · 2.12 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
65
66
67
68
69
70
71
72
73
import { rmSync, writeFileSync } from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import electron, { onstart } from 'vite-plugin-electron'
import pkg from './package.json'
rmSync('release', { recursive: true, force: true })
rmSync('dist', { recursive: true, force: true })
writeFileSync("./playground/index.html", "<h1>文件夹是空的,不会被打包,所以写入这个文件</h1>");
writeFileSync("./logs/index.html", "<h1>文件夹是空的,不会被打包,所以写入这个文件</h1>");
// 打包前与打包后的结构
// database database
// src dist
// node_modules node_modules
// temp temp
export default defineConfig({
build: {
outDir: 'dist/ui',
},
base: './',
root: './',
plugins: [
vue(),
electron({
// 这个插件负责打包main和preload
// ui部分的代码由vite负责打包
main: {
entry: 'src/main/index.ts',
vite: {
build: {
// For Debug
sourcemap: true,
outDir: 'dist/main',
},
// Will start Electron via VSCode Debug
plugins: [process.env.VSCODE_DEBUG ? onstart() : null],
},
},
preload: {
input: {
// You can configure multiple preload here
index: path.join(__dirname, 'src/preload/index.ts'),
},
vite: {
build: {
// For Debug
sourcemap: 'inline',
outDir: 'dist/preload',
},
},
},
// Enables use of Node.js API in the Renderer-process
// https://github.com/electron-vite/vite-plugin-electron/tree/main/packages/electron-renderer#electron-renderervite-serve
renderer: {
// Enables use of Node.js API in the Renderer-process
nodeIntegration: true,
// Like Vite's pre bundling
optimizeDeps: {
include: [
'node-pty'
],
},
},
}),
],
server: process.env.VSCODE_DEBUG ? {
host: pkg.debug.env.VITE_DEV_SERVER_HOSTNAME,
port: pkg.debug.env.VITE_DEV_SERVER_PORT,
} : undefined,
})