-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
55 lines (51 loc) · 1.37 KB
/
electron.vite.config.ts
File metadata and controls
55 lines (51 loc) · 1.37 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
import { resolve } from "path"
import { readFileSync, copyFileSync, existsSync, mkdirSync } from "fs"
import { defineConfig } from "electron-vite"
import react from "@vitejs/plugin-react"
import tailwindcss from "@tailwindcss/vite"
const pkg = JSON.parse(readFileSync("./package.json", "utf-8"))
// Plugin to copy resources to output
function copyResources(): { name: string; closeBundle: () => void } {
return {
name: "copy-resources",
closeBundle(): void {
const srcIcon = resolve("resources/icon.png")
const destDir = resolve("out/resources")
const destIcon = resolve("out/resources/icon.png")
if (existsSync(srcIcon)) {
if (!existsSync(destDir)) {
mkdirSync(destDir, { recursive: true })
}
copyFileSync(srcIcon, destIcon)
}
}
}
}
export default defineConfig({
main: {
// Bundle all dependencies into the main process
build: {
lib: {
entry: "src/main/index.ts",
formats: ["cjs"]
},
rollupOptions: {
external: ["electron"],
plugins: [copyResources()]
}
}
},
preload: {},
renderer: {
define: {
__APP_VERSION__: JSON.stringify(pkg.version)
},
resolve: {
alias: {
"@": resolve("src/renderer/src"),
"@renderer": resolve("src/renderer/src")
}
},
plugins: [react(), tailwindcss()]
}
})