Electron-builder: Question about files/extraFiles/extraResources

Created on 14 Mar 2018  ยท  5Comments  ยท  Source: electron-userland/electron-builder

version: 20.4.1

I'm having trouble understanding some problems and restrictions that I ran into with files/extraFiles/extraResources configuration. I've read all possible documentations that I could find, and it still isn't clear to me. Please help me understand.

Assuming the following project structure:

โ”œโ”€โ”€ app
โ”‚ย ย  โ”œโ”€โ”€ index.html
โ”‚ย ย  โ””โ”€โ”€ index.js
โ”œโ”€โ”€ electron
โ”‚ย ย  โ”œโ”€โ”€ main.js
โ”‚ย ย  โ”œโ”€โ”€ pack.js
โ”‚ย ย  โ””โ”€โ”€ package.json
โ””โ”€โ”€ package.json

/app is the application that I wish to release as a web application AND package as an electron app.
/electron is a packaging helper project that uses electron-builder; it is also the "app root" for electron-builder
/electron/pack.js is a node script that runs the electron-builder api.

Now the question is, how do I include files from /app into the electron app?

  1. I read in several places (eg. #597) that the paths should be "relative to the (electron) project directory". The term "relative" usually means that I should be able to specify something like '../app/**/*' -- this is a valid relative path. However I don't think "relative" means what I think it means in this case. It seems like "relative" means that the file/directory must be contained within the electron project directory. Please correct me if I'm wrong.
  2. If files must be from within the electron project directory, maybe "relative" is not the most accurate term to use? It is really easy to think that I could specify either relative or absolute path for files/extraFiles/extraResource, but this clearly doesn't work for files outside of the electron project directory.
  3. Why can't I use absolute path or relative path that points outside of the electron project? I know nothing about how build-electron works underneath, but I thought we're simply copying files and directories, so I really don't understand why there is such restriction.

NOTE: I discovered the following while I was testing and writing up this issue:

Relative path will only work if you use Fileset.from, and it cannot be a glob pattern

This works

files: [
  {from: '../app/', to: '.'}
]

This doesn't work (Fileset + glob pattern)

files: [
  {from: '../app/**/*', to: '.'}
]

This doesn't work (relative path without using Fileset)

files: [
  '../app/'
]

I feel this is something that developers should be able to know by reading the documentation, but I had to figure it out through trial and error. Hope this will be useful to others who happen to across the same issue.

backlog

Most helpful comment

I would really like to see a warning when use String or Array String and files are missing also.

Is there a way to make electron-builder treat warnings as errors?

All 5 comments

I've also found that when running with DEBUG=electron-builder, only the FileSet versions gives us a "file source doesn't exist" warning:
screenshot_2018-04-28_11-54-05

When using a String or Array String, no warning is visible. Here I ran the same code as above, but with

  "build": {
    "appId": "com.gingkoapp.desktop",
    "extraResources": "xyznonsensepath",
...

And I don't get a warning:
screenshot_2018-04-28_11-57-58

Improving the docs would be important, but I think most people would be able to figure things out if we had warnings when a file isn't found, along with the path it tried.

Im trying to understand where eventually this extra resources being installed. I can package extraResources and see them in dmg file but i don't see this folder anywhere being created on destination machine

I'm pretty sure its being installed in the temp folder while being run

I would really like to see a warning when use String or Array String and files are missing also.

Is there a way to make electron-builder treat warnings as errors?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings