forked from Comfy-Org/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.base.config.ts
46 lines (40 loc) · 1.33 KB
/
vite.base.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
import { builtinModules } from 'node:module';
import type { ConfigEnv, Plugin, UserConfig } from 'vite';
import pkg from './package.json';
export const builtins = ['electron', ...builtinModules.map((m) => [m, `node:${m}`]).flat()];
export const external = [
...builtins,
...Object.keys('dependencies' in pkg ? (pkg.dependencies as Record<string, unknown>) : {}),
];
export function getBuildConfig(env: ConfigEnv): UserConfig {
const { mode, command } = env;
return {
mode,
build: {
// Prevent multiple builds from interfering with each other.
emptyOutDir: false,
// 🚧 Multiple builds may conflict.
outDir: '.vite/build',
watch: command === 'serve' ? {} : null,
minify: command === 'build',
},
clearScreen: false,
define: {
__COMFYUI_VERSION__: JSON.stringify(pkg.config.comfyVersion),
},
};
}
export function pluginHotRestart(command: 'reload' | 'restart'): Plugin {
return {
name: '@electron-forge/plugin-vite:hot-restart',
closeBundle() {
if (command === 'reload') {
// TODO: Send message to external renderer dev server for reload.
} else {
// Main process hot restart.
// https://github.com/electron/forge/blob/v7.2.0/packages/api/core/src/api/start.ts#L216-L223
process.stdin.emit('data', 'rs');
}
},
};
}