Electron-builder: build directory not being included in asar archive

Created on 5 Dec 2016  路  3Comments  路  Source: electron-userland/electron-builder

  • Version: 10.5.0

  • Target: darwin


I use webpack to build my application and have it set to write generated bundles to ./build in the project directory. I run both the main process entry and the render process through webpack, so my "main" entry in package.json is:

"main": "./build/main.bundle.js",

When running electron-builder I continually get an error message indicating that the files in the build directory are not being included in the generated Resources/app.asar archive. I've tried adding them explicitly in numerous ways: I've tried:

  • setting "build.extraFiles" in package.json to [ "build/*", "build/**/*" ]
  • setting "build.extraResources" in package.json to [ "build/*", "build/**/*" ]
  • Explicitly setting "build.files" in package.json to [ "build", "node_modules" ] (I thought perhaps that since "build" is an entry in my .gitignore, it might be worth explicitly setting the files I wanted to include)

Relevant snippet of package.json:

  "build": {
    "appId": "com.antonycourtney.tad",
    "category": "DataVisualization",
    "files": [
      "build",
      "node_modules"
    ]
  },

Error message I see is below. Unfortunately I'm including some native code library dependencies, so it takes more than a minute to build those native libraries before I get the error message below.

Is there any way to debug the file globs to see what's going in to (or excluded from) the generated asar archive, and why? Is there anything magical about the directory named 'build' that prevents it from being included? Any examples of another project using webpack and electron-builder?
Any help greatly appreciated. Thank You!

Gamma:tad antony$ npm run dist

> [email protected] dist /Users/antony/home/src/tad
> build

Rebuilding native production dependencies for arch x64
Packaging for darwin x64 using electron 1.4.7 to dist/mac
鈿狅笍  Application icon is not set, default Electron icon will be used
Error: Application entry file "build/main.bundle.js" in the "/Users/antony/home/src/tad/dist/mac/Tad.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
...
question

Most helpful comment

alright finally make it work: add the main.js into the files then it can find it now

All 3 comments

Root directory build it is build resources directory by default, please see https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources

You need to change buildResources option.

it still doesn't work
I added
"directories": { "buildResources": "./electron-config", //contains main.js "output": "dist" },
and I updated my main: "electron-config/main.js" also tried main.js ./main.js I got the same error again

alright finally make it work: add the main.js into the files then it can find it now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ajeey picture Ajeey  路  3Comments

StickNitro picture StickNitro  路  3Comments

NPellet picture NPellet  路  3Comments

lbssousa picture lbssousa  路  3Comments

popod picture popod  路  3Comments