fix(electron): point main + preload + index paths at the real build layout
npm run dev failed with ERR_MODULE_NOT_FOUND for dist-electron/services/inputHelper. Root cause: the electron program includes src runtime files (repositories, layoutProfile, ocrPreprocess), so tsc's inferred rootDir is the project root and it emits the entry at dist-electron/electron/main.js (with src at dist-electron/src). package.json "main" still pointed at a stale flat dist-electron/main.js fossil from an older build layout, whose extensionless imports don't resolve under NodeNext ESM. - package.json main -> dist-electron/electron/main.js. - predev/build copy preload.cjs into dist-electron/electron/ (next to main.js, where main.ts resolves it via __dirname). - main.ts loads ../../dist/index.html (one level deeper now) for the packaged window + overlay. Verified: clean electron build emits only the nested layout; electron . loads the main process past module resolution (only ERR_CONNECTION_REFUSED for the dev server, expected standalone); npm run build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -394,7 +394,7 @@ function createMainWindow() {
|
|||||||
if (isDev) {
|
if (isDev) {
|
||||||
mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL!);
|
mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL!);
|
||||||
} else {
|
} else {
|
||||||
mainWindow.loadFile(path.join(__dirname, "../dist/index.html"));
|
mainWindow.loadFile(path.join(__dirname, "../../dist/index.html"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +528,7 @@ function createOverlayWindow() {
|
|||||||
if (isDev) {
|
if (isDev) {
|
||||||
overlayWindow.loadURL(`${process.env.VITE_DEV_SERVER_URL!}?overlay=1`);
|
overlayWindow.loadURL(`${process.env.VITE_DEV_SERVER_URL!}?overlay=1`);
|
||||||
} else {
|
} else {
|
||||||
overlayWindow.loadFile(path.join(__dirname, "../dist/index.html"), {
|
overlayWindow.loadFile(path.join(__dirname, "../../dist/index.html"), {
|
||||||
query: { overlay: "1" },
|
query: { overlay: "1" },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -3,14 +3,14 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Local Windows assistant for scanning Genshin artifacts and suggesting no-brainer builds.",
|
"description": "Local Windows assistant for scanning Genshin artifacts and suggesting no-brainer builds.",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/electron/main.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"predev": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts\\kill-stale-instances.ps1 && tsc -p tsconfig.electron.json && copy electron\\preload.cjs dist-electron\\preload.cjs",
|
"predev": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts\\kill-stale-instances.ps1 && tsc -p tsconfig.electron.json && copy electron\\preload.cjs dist-electron\\electron\\preload.cjs",
|
||||||
"dev": "concurrently -k \"vite --host 127.0.0.1\" \"wait-on tcp:5173 && cross-env VITE_DEV_SERVER_URL=http://127.0.0.1:5173 electron .\"",
|
"dev": "concurrently -k \"vite --host 127.0.0.1\" \"wait-on tcp:5173 && cross-env VITE_DEV_SERVER_URL=http://127.0.0.1:5173 electron .\"",
|
||||||
"dev:web": "vite --host 127.0.0.1",
|
"dev:web": "vite --host 127.0.0.1",
|
||||||
"dev:admin": ".\\dev-admin.cmd",
|
"dev:admin": ".\\dev-admin.cmd",
|
||||||
"build": "tsc && vite build && tsc -p tsconfig.electron.json && copy electron\\\\preload.cjs dist-electron\\\\preload.cjs",
|
"build": "tsc && vite build && tsc -p tsconfig.electron.json && copy electron\\\\preload.cjs dist-electron\\\\electron\\\\preload.cjs",
|
||||||
"preview": "vite preview --host 127.0.0.1",
|
"preview": "vite preview --host 127.0.0.1",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"lint": "tsc --noEmit",
|
"lint": "tsc --noEmit",
|
||||||
|
|||||||
Reference in New Issue
Block a user