fix(desktop/esbuild): asset path not working at runtime

This commit is contained in:
Elian Doran 2025-05-23 17:56:44 +03:00
parent 64b4869939
commit 43d9f77518
No known key found for this signature in database
2 changed files with 3 additions and 7 deletions

View File

@ -9,8 +9,6 @@ import escape from "escape-html";
import sanitize from "sanitize-filename"; import sanitize from "sanitize-filename";
import mimeTypes from "mime-types"; import mimeTypes from "mime-types";
import path from "path"; import path from "path";
import { fileURLToPath } from "url";
import { dirname, join } from "path";
import type NoteMeta from "./meta/note_meta.js"; import type NoteMeta from "./meta/note_meta.js";
import log from "./log.js"; import log from "./log.js";
import { t } from "i18next"; import { t } from "i18next";
@ -299,7 +297,7 @@ export function getResourceDir() {
return path.dirname(process.argv[1]); return path.dirname(process.argv[1]);
} }
return join(dirname(fileURLToPath(import.meta.url)), ".."); return path.join(__dirname, "..");
} }
// TODO: Deduplicate with src/public/app/services/utils.ts // TODO: Deduplicate with src/public/app/services/utils.ts

View File

@ -10,10 +10,8 @@ import keyboardActionsService from "./keyboard_actions.js";
import electron from "electron"; import electron from "electron";
import type { App, BrowserWindowConstructorOptions, BrowserWindow, WebContents } from "electron"; import type { App, BrowserWindowConstructorOptions, BrowserWindow, WebContents } from "electron";
import { formatDownloadTitle, isDev, isMac, isWindows } from "./utils.js"; import { formatDownloadTitle, isDev, isMac, isWindows } from "./utils.js";
import { fileURLToPath } from "url";
import { dirname } from "path";
import { t } from "i18next"; import { t } from "i18next";
import { RESOURCE_DIR } from "./resource_dir.js";
// Prevent the window being garbage collected // Prevent the window being garbage collected
let mainWindow: BrowserWindow | null; let mainWindow: BrowserWindow | null;
@ -259,7 +257,7 @@ async function configureWebContents(webContents: WebContents, spellcheckEnabled:
} }
function getIcon() { function getIcon() {
return path.join(dirname(fileURLToPath(import.meta.url)), "../../images/app-icons/png/256x256" + (isDev ? "-dev" : "") + ".png"); return path.join(RESOURCE_DIR, "images/app-icons/png/256x256" + (isDev ? "-dev" : "") + ".png");
} }
async function createSetupWindow() { async function createSetupWindow() {