Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron - missing icons folder in build #11087

Closed
2 of 14 tasks
hawkeye64 opened this issue Oct 24, 2021 · 0 comments · Fixed by #11088
Closed
2 of 14 tasks

Electron - missing icons folder in build #11087

hawkeye64 opened this issue Oct 24, 2021 · 0 comments · Fixed by #11088

Comments

@hawkeye64
Copy link
Member

hawkeye64 commented Oct 24, 2021

Describe the bug
When quasar build -m electron is issued, the src-electron/icons folder is not copied to the dist/electron/unpackaged folder and therefore will not be packaged into the final electron build.

Codepen/jsFiddle/Codesandbox (required)
Fork a Codepen (https://codepen.quasar.dev) or a jsFiddle (https://jsfiddle.quasar.dev) or a Codesandbox (https://codesandbox.quasar.dev) and hit save then copy-paste link here.

To Reproduce
Steps to reproduce the behavior:

  1. run quasar build -m electron
  2. go to the dist/electron/unpackaged folder
  3. you will see it's missing the icons folder

Expected behavior
You'd expect the icons folder to be copied over

Screenshots
image

I have verified this for both Linux and Windows, but have not for Mac (but, assume it's the same)

Platform (please complete the following information):
Quasar Version:
@quasar/app Version:
Build mode........ electron
Pkg quasar........ v2.1.9
Pkg @quasar/app... v3.1.5

Quasar mode:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

Tested on:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

OS: windows 11/ubuntu 20.04.3
Node: 14.18.1
NPM: 6.14.15
Yarn: 1.22.15
Browsers:
iOS:
Android:
Electron:
"electron": "^15.3.0",
"electron-builder": "^22.4.0",
"electron-packager": "^15.2.0",

Additional context
I tried to find the code in @quasar/app that should do the copying but have not located it yet. I did set a breakpoint in vs code to stop the build. I manually copied the icons folder to unpackaged. I then let the build continue. When running the output on Ubuntu, the icon now shows up for the running app. On windows, the executable and setup both have embedded icons, and running the app shows the icon on the dock bar.

Also, for the icons to work, I added the following code in electron-main.js (note: this also works for dev):

const iconPath = path.resolve(__dirname, 'icons',
  os.platform === 'win32' ? 'icon.ico'
    : os.platform === 'darwin' ? 'icon.icns'
      : 'linux-512x512.png'
)

function createWindow () {
  /**
   * Initial window options
   */
  mainWindow = new BrowserWindow({
    icon: iconPath, // <-- here
    width: 1000,
    height: 600,
    useContentSize: true,
    webPreferences: {
      contextIsolation: true,
      // More info: /quasar-cli/developing-electron-apps/electron-preload-script
      preload: path.resolve(__dirname, process.env.QUASAR_ELECTRON_PRELOAD)
    }
  })

If I can figure this out, I will create a PR.

rstoenescu added a commit that referenced this issue Oct 29, 2021
* fix(app): Electron - missing icons folder in build (#11087)

* fix(app) - additional changes to electron-main.js

The fixes include:
1. 'process.platform' is undefined if `nodeIntegration` is not true. Fall back to using `os.platform()`
2. Resolve which icon to use based on platform Electron is running on
3. Inject icon path into BrowserWindow (with previous commit this now works with both dev and build)

* revert(app): fse.copySync for electron icons

* feat(app): use CopyWebpackPlugin to copy electron icons

* chore(app): modified a comment

* Update create-chain.js

Co-authored-by: Razvan Stoenescu <razvan.stoenescu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant