-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathelectron.vite.config.ts
More file actions
76 lines (74 loc) · 1.92 KB
/
electron.vite.config.ts
File metadata and controls
76 lines (74 loc) · 1.92 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { resolve } from "path";
import { defineConfig, externalizeDepsPlugin } from "electron-vite";
import react from "@vitejs/plugin-react";
import type { Plugin } from "vite";
// Stub Capacitor modules for desktop dev server (they only run on mobile)
const CAPACITOR_MODULES = [
"@capacitor/core",
"@capacitor/filesystem",
"@capacitor/browser",
];
function stubCapacitorPlugin(): Plugin {
return {
name: "stub-capacitor",
resolveId(id) {
if (CAPACITOR_MODULES.includes(id)) return "\0" + id;
},
load(id) {
if (id.startsWith("\0@capacitor/"))
return "export default {}; export const CapacitorHttp = {}; export const Filesystem = {}; export const Directory = {}; export const Browser = {};";
},
};
}
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
build: {
rollupOptions: {
input: {
index: resolve(__dirname, "electron/main.ts"),
},
external: ["sql.js"],
},
},
},
preload: {
plugins: [externalizeDepsPlugin()],
build: {
rollupOptions: {
input: {
index: resolve(__dirname, "electron/preload.ts"),
},
},
},
},
renderer: {
root: ".",
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@mobile": resolve(__dirname, "mobile/src"),
},
},
plugins: [stubCapacitorPlugin(), react()],
build: {
rollupOptions: {
input: resolve(__dirname, "index.html"),
// Externalize Capacitor modules - they're only used in mobile builds
external: CAPACITOR_MODULES,
},
},
optimizeDeps: {
include: ["onnxruntime-web", "upscaler", "@huggingface/transformers"],
exclude: ["@google/model-viewer"],
},
server: {
port: 5173,
strictPort: false, // Auto-find available port if 5173 is in use
host: "0.0.0.0",
},
worker: {
format: "es",
},
},
});