Skip to content

Commit 4c9ba8d

Browse files
committed
fix: Dynamically resolve Electron app icon path and ensure resources are correctly packaged.
1 parent eb0cc99 commit 4c9ba8d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/desktop-app/electron-builder.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ extraResources:
2020
- from: dist/core/config.js
2121
to: core/config.js
2222

23-
- resources/**
23+
- from: resources
24+
to: .
25+
filter:
26+
- '**/*'
2427
executableName: munliwall
2528

2629
linux:

packages/desktop-app/src/main/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { startWallpaperService } from '@munlicode/munliwall-core'
1212
import { registerIPCHandlers } from './handlers/index.js'
1313
import { createMenu } from './menu.js'
1414
import path from 'path'
15-
import icon from '../../resources/icon.png?asset'
1615

1716
const currentDir = __dirname
1817
const projectRoot = path.join(currentDir, '../../../../')
@@ -22,13 +21,22 @@ if (process.env.NODE_ENV === 'development') {
2221
}
2322
const preloadPath = path.join(__dirname, '../preload/index.js')
2423

24+
function getIconPath(): string {
25+
if (app.isPackaged) {
26+
// In production, extraResources copies resources/ directly to the resources folder
27+
return path.join(process.resourcesPath, 'icon.png')
28+
}
29+
// In development, resolve relative to this file
30+
return path.join(__dirname, '../../resources/icon.png')
31+
}
32+
2533
function createWindow(): void {
2634
const win = new BrowserWindow({
2735
width: 1200,
2836
height: 800,
2937
show: false,
3038
autoHideMenuBar: true,
31-
...(process.platform === 'linux' ? { icon } : {}),
39+
icon: getIconPath(),
3240
webPreferences: {
3341
preload: preloadPath,
3442
sandbox: false

0 commit comments

Comments
 (0)