Electron-builder: extraResources get copied to the wrong folder on Linux/Windows

Created on 5 May 2016  ยท  15Comments  ยท  Source: electron-userland/electron-builder

I am trying to build a .deb, and the folder that I specify in extraResources ends up in the wrong place.

Config:

"build": {
    "app-bundle-id": "apple.app.id",
    "app-category-type": "public.app-category.utilities",
    "productName": "Product",
    "asar": false,
    "extraResources": ["dist/"],
    "osx": {
      "background": "app/assets/bg.jpg",
      "icon": "build/icons/app.icns"
    },
    "linux": {
    }
  },
  "directories": {
    "output": "release"
  },

The intermediate packager output looks like

release/
|-Product-linux-x64/
  |-...
  |-resources/
  |-dist/
  |-...

When I install and run the .deb I electron gives me file not found errors looking for resources/dist/bundle.js and resources/dist/bundle.css.

backlog help wanted invalid question readme improvement

Most helpful comment

Hey @develar, thanks for answering!

I'm building my app with webpack so the distinction between 'application source code' and 'built javascript app' is important, and I got confused about which corresponded to the electron-builder 'app' folder (it's the built javascript app). So basically I was packaging up my source code and then trying to copy in the actual app ๐Ÿ˜„.

My working setup now looks like this:

  • src/ folder for my source code (es6) that will be compiled through webpack
  • app/ folder for my static source (main.js, app.html, etc.), built assets (bundle.js, bundle.css, etc), and package.json describing any external app dependencies that can't be packaged with webpack (native dependencies mostly).
  • build/ folder for electron-builder related assets (icons, etc.)
  • asar turned off since it's irrelevant when your entire app is ~4 files, and also it breaks ffi.Library

This is a project using a similar setup: https://github.com/xwartz/douban.fm. Would be worth, I think, adding a sentence to the documentation for people with related setups.

All 15 comments

The problem is that you don't understand correctly for what this option is. I will fix docs.

We do not copy extra resources into your app, we copy extra resources into your "executable". Why?

"
Our library is dependant on qt libraries (must be located at the application root folder) and also some qt plugin dlls must be exactly at specific relative paths (for example ./platforms/qwindows.dll and ./printsupport/windowsprintersupport.dll) or app crashes with an error on node-ffi library load. It's Qt's requirement and we can't simply restructure it.
"

As far I see in your pull request (thanks that you decided to contribute), you want to copy files into your js app.

Please explain โ€” why you cannot just use these files as part of your app? Please note โ€“ your app files should be packed into asar archive due to performance (especially on Windows). And we pack into asar by default. If you want to access some files directly (exec, spawn), you should use asar-unpack (https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#asar-unpack).

Feel free to reopen when you will have time to answer.

Hey @develar, thanks for answering!

I'm building my app with webpack so the distinction between 'application source code' and 'built javascript app' is important, and I got confused about which corresponded to the electron-builder 'app' folder (it's the built javascript app). So basically I was packaging up my source code and then trying to copy in the actual app ๐Ÿ˜„.

My working setup now looks like this:

  • src/ folder for my source code (es6) that will be compiled through webpack
  • app/ folder for my static source (main.js, app.html, etc.), built assets (bundle.js, bundle.css, etc), and package.json describing any external app dependencies that can't be packaged with webpack (native dependencies mostly).
  • build/ folder for electron-builder related assets (icons, etc.)
  • asar turned off since it's irrelevant when your entire app is ~4 files, and also it breaks ffi.Library

This is a project using a similar setup: https://github.com/xwartz/douban.fm. Would be worth, I think, adding a sentence to the documentation for people with related setups.

Thank you for detailed answer.

So, now there are no issues and all is ok?

FYI: https://github.com/electron-userland/electron-builder/issues/326#issuecomment-211124807

Reopened โ€” must be documented.

Yep, seems to be working well now! Tested on Mac and Debian so far.

On Thursday, May 12, 2016, Vladimir Krivosheev [email protected]
wrote:

Thank you for detailed answer.

So, now there are no issues and all is ok?

FYI: #326 (comment)
https://github.com/electron-userland/electron-builder/issues/326#issuecomment-211124807

Reopened โ€” must be documented.

โ€”
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/electron-userland/electron-builder/issues/379#issuecomment-218660802

Hi, I'm having the same issue with my app. I read the whole Issue and thought it was not useful to create a new one.

I'm building an app with the Widevine module and after building on Windows, the extraResources are not located in resources folder.

Here is my conf :

"osx": {
      ...
      "extraResources": [
        "WidevineCDM/darwin"
      ]
    },
    "win": {
      ...
      "extraResources": [
        "WidevineCDM/win32/${arch}"
      ]
}

The thing that I don't understand, is why on OSX the extraResources are located beside my generated app.asar file in "Resources" and not on Windows ?

I wanted to use extraResources and not put these files directly in my app folder because I don't want to include others OS libs in my app and I also want to be able to "asar" my app. I can't "asar" my app if I have to include lib in it.

@jbleuzen If I understand correctly โ€” you get _different_ result using the same configuration on OS X and Windows (you build app for windows on OS X and result is not equal to result if build for windows on Windows)?

@jbleuzen Ah, I see โ€” your question is why we put extraResources for OS X app into Contents/Resources, but not into Contents?

Answering the second question : Yes it doesn't look "homogeneous" (if I may use this word)....
On OSX I'm loading the widevine library using : ${__dirname}/../WidevineCDM/myfile and on Windows I would need to load the plugin with : ${__dirname}/../../WidevineCDM/myfile.

If the extraResources goes into resources, I don't have this problem... :/

Fix:

  • extraResources must copy files into the same dir where electron app located (app.asar).
  • In addition to extraResources, extraFiles must be added to copy files as extraResources does before with one exception โ€“ on OS X into the Contents.

Will be implemented in the next major release.

Yes that will be a good implementation...
Thanks

@jbleuzen Please try 4.x

Yes, it works with the 0.4.0 you can close in my opinion !

Would be worth, I think, adding a sentence to the documentation for people with related setups.

Help wanted. https://github.com/electron-userland/electron-builder/blob/master/CONTRIBUTING.md#documentation

Thank you very much.
Thanks

Was this page helpful?
0 / 5 - 0 ratings