electron / electron/forge

image cannot be resolved when application is packed

Open
#3,621 7 comments 3 reactions 0 assignees View on GitHub
documentation package
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 17m
Merged PRs (30d)
32

Description

### Pre-flight checklist

- [X] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

### Electron Forge version

6.1.1

### Electron version

24.0.0

### Operating system

Ubuntu 22.04

### Last known working Electron Forge version

_No response_

### Expected behavior

When using electron forge webpack typescript template. The image should be packed and resolved when npm run package or npm run make

### Actual behavior

I got this code for tray icon:

```typescript
// some code
const icon = nativeImage.createFromPath(
path.resolve("./src/assets/xnauta.png")
);
const tray = new Tray(icon);
// some more code
console.log("testing the path ", path.resolve("./src/assets/xnauta.png"));

```
if I run npm start , the tray icon is rendered correctly. icon path path is resolved to :
/home/yosle/projects/xnauta-electron/src/assets/xnauta.png

When executing after npm run package or pn run make, tray icon is not rendered , and icon path is resolved to :
/home/yosle/projects/xnauta-electron/out/xnauta-linux-x64/resources/app/.webpack/main/assets/xnauta.png
If I navigate to this folder , the file doesn't exist.

Also tried this on Windows with similar result, tray icon is not shown, but tray menu options are displayed

![Captura desde 2024-06-07 12-48-21](https://github.com/electron/forge/assets/86306314/35cfae82-12b5-4663-b76c-cb69c7fdc4ea)

### Steps to reproduce

run app with npm start, Tray icon is rendered correctly:
![Captura desde 2024-06-07 12-45-06](https://github.com/electron/forge/assets/86306314/8612409c-7c76-489c-8663-7d44abcc0c0c)

run npm run package and execute the binary or run npm run make , install the deb package and execute the app:
![Captura desde 2024-06-07 12-44-03](https://github.com/electron/forge/assets/86306314/89d67383-4a46-4767-aade-aedc94dc369a)

### Additional information

if I run npm start , the tray icon is rendered correctly. icon path path is resolved to :
/home/yosle/projects/xnauta-electron/src/assets/xnauta.png

When executing after npm run package, tray icon is not rendered , and icon path is resolved to :
/home/yosle/projects/xnauta-electron/out/xnauta-linux-x64/resources/app/.webpack/main/assets/xnauta.png
If I navigate to this folder , the file doesn't exist.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.