Electron – How to add external files?

Managed to solve it by using extraResources. Should be declared under build in your package.json file.

For example:

  1. Create a new folder named extraResources adjacent to pacakge.json

  2. Add the following code to your package.json file:

    "build": {
        "extraResources": ["./extraResources/**"]
    }
    
  3. Then, you can access the files inside this folder by using __dirname + '/../extraResources/' from your main app.

Leave a Comment