-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
62 lines (56 loc) · 1.58 KB
/
electron.vite.config.ts
File metadata and controls
62 lines (56 loc) · 1.58 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
import { resolve } from 'path'
import { defineConfig } from 'electron-vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { copyFileSync, mkdirSync, existsSync, readdirSync, statSync } from 'fs'
import { join } from 'path'
// 复制迁移文件的插件
function copyMigrationsPlugin() {
return {
name: 'copy-migrations',
closeBundle() {
const srcDir = resolve('src/main/db/migrations')
const destDir = resolve('out/main/db/migrations')
// 递归复制目录
function copyDir(src: string, dest: string) {
if (!existsSync(dest)) {
mkdirSync(dest, { recursive: true })
}
const entries = readdirSync(src)
for (const entry of entries) {
const srcPath = join(src, entry)
const destPath = join(dest, entry)
if (statSync(srcPath).isDirectory()) {
copyDir(srcPath, destPath)
} else {
copyFileSync(srcPath, destPath)
}
}
}
if (existsSync(srcDir)) {
copyDir(srcDir, destDir)
console.log('[Migrations] Copied migration files to', destDir)
}
}
}
}
export default defineConfig({
main: {
plugins: [copyMigrationsPlugin()],
build: {
rollupOptions: {
external: ['remark', 'remark-gfm', 'remark-parse', 'unified', 'unist-util-visit']
}
}
},
preload: {},
renderer: {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src'),
'@': resolve('src/renderer/src')
}
},
plugins: [tailwindcss(), react()]
}
})