Skip to content

Instantly share code, notes, and snippets.

@fodra
Created December 18, 2017 06:29
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fodra/d6c4572a0c6f0c405e6c2f35a09efb78 to your computer and use it in GitHub Desktop.
Save fodra/d6c4572a0c6f0c405e6c2f35a09efb78 to your computer and use it in GitHub Desktop.
Command to add extra resources in your electron app

This is the example usage of electron-packager that I never found online anywhere else.

To add resource.exe and resource2.dll in the resource folder when you create an installer, this is how you do it with the --extra-resource commandline switch.

--extra-resource

electron-packager . --overwrite --asar --extra-resource="resource1.exe" --extra-resource="resource2.dll" --platform=win32 --arch=ia32 --icon=./frontend/dist/assets/icon.ico --prune=true --out=./build --version-string.ProductName='Hot Pan de sal'

within the backend code you can refer to the files as:

"./resources/resource1.exe"

@Aadityajoshi151
Copy link

Aadityajoshi151 commented Sep 3, 2021

Thank you very much for this.
I had a sound effect in the assets folder. The assets folder was adjacent to package.json.
I used --extra-resource="assets/shutter.mp3" in package.json file. It adds the resource in the "resources" folder after packaging.
For referring to this file in the code, I used:
const path = require('path'); const filePath = path.join(process.resourcesPath, "shutter.mp3");
Worked flawlessly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment