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

Question about files/extraFiles/extraResources #2693

Closed
tmchng opened this issue Mar 14, 2018 · 11 comments
Closed

Question about files/extraFiles/extraResources #2693

tmchng opened this issue Mar 14, 2018 · 11 comments
Labels

Comments

@tmchng
Copy link

tmchng commented Mar 14, 2018

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:

project
├── 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. extraResources parent directory #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.

@AdrianoFerrari
Copy link
Contributor

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.

@ovsokolov
Copy link

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

@yoav-shaham
Copy link

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

@shearer12345
Copy link

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?

@stale
Copy link

stale bot commented Jul 2, 2019

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.

@stale stale bot added the backlog label Jul 2, 2019
@stale stale bot closed this as completed Jul 9, 2019
@temoke-levelops
Copy link

It's so frustrating that this isn't in the docs. u_u

@m4heshd
Copy link

m4heshd commented Jan 31, 2021

@develar can we add this to the docs?

@thien-do
Copy link

Thank you for having this issue! It saves me a huge time. Let me try to make a PR for this

@thien-do
Copy link

Related: #1912

@livthomas
Copy link

I agree that this part of the documentation is not written very well. I spend a lot of time trying to copy a folder. I was only able to copy a single file. But after reading this thread, I realized I can skip the filter parameter and then it started working.

@fstanchina
Copy link

I'm not sure if this is the proper place to write this, so please redirect me elsewhere if necessary.
We were just bitten by a missing extraResources file. Someone forgot to compile a small tool, so we released our app without a required piece. We were fully expecting an error and a failed build if a file was missing. Our fault for not checking this before, but this seems like a rather catastrophic bug to me.
Either a file is needed, or it isn't. There's no reason to put a file in extraResources if it isn't actually used, so why no error if it's missing? Is there a way to tell the builder a file is necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants