question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about files/extraFiles/extraResources

See original GitHub issue

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. #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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:20
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
shearer12345commented, Jul 24, 2018

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?

2reactions
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found