forked from oliverschwendener/ueli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mts
85 lines (83 loc) · 3 KB
/
vite.config.mts
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
74
75
76
77
78
79
80
81
82
83
84
85
import react from "@vitejs/plugin-react";
import { join } from "path";
import { defineConfig } from "vite";
import electron from "vite-plugin-electron";
import renderer from "vite-plugin-electron-renderer";
import pkg from "./package.json";
export default defineConfig(({ command }) => {
const isServe = command === "serve";
const isBuild = command === "build";
const sourcemap = isServe ? "inline" : undefined;
return {
root: "src/renderer",
resolve: {
alias: {
"@common": join(__dirname, "src", "common"),
"@Core": join(__dirname, "src", "renderer", "Core"),
},
},
build: {
outDir: "../../dist-renderer",
emptyOutDir: true,
chunkSizeWarningLimit: 1000,
},
plugins: [
react(),
electron([
{
entry: "src/main/index.ts",
onstart(options) {
options.startup();
},
vite: {
resolve: {
alias: {
"@common": join(__dirname, "src", "common"),
"@Core": join(__dirname, "src", "main", "Core"),
},
},
build: {
sourcemap,
minify: isBuild,
outDir: "dist-main",
emptyOutDir: true,
rollupOptions: {
external: Object.keys("dependencies" in pkg ? pkg.dependencies : {}),
},
},
},
},
{
entry: "src/preload/index.ts",
onstart(options) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
options.reload();
},
vite: {
resolve: {
alias: {
"@common": join(__dirname, "src", "common"),
},
},
build: {
sourcemap,
minify: isBuild,
outDir: "dist-preload",
emptyOutDir: true,
rollupOptions: {
external: Object.keys("dependencies" in pkg ? pkg.dependencies : {}),
},
},
},
},
]),
renderer(),
],
server: (() => ({
host: "127.0.0.1",
port: 7777,
}))(),
clearScreen: false,
};
});