Electron-builder: Exclude a directory while packaging

Created on 21 Nov 2016  ·  5Comments  ·  Source: electron-userland/electron-builder

  • Version:
    8.7.0
  • Target:
    OSX

    I'm using electron-builder to package my app. While building installers I want to exclude a directory (which is junk and have no real use) which resides in my app/node_modules/@paulcbetts/cld/deps/cld . As of now I manually delete it and then run npm run dist to package. Is there any way I can exclude it while building?

@develar any help would be highly appreciated since that folder is taking ~120MB of my app size 😭

feature question

Most helpful comment

@develar you're awesome. Thank you so much ❤️ . To make it work correctly I had to use it like this -

"files": [
     "**/*",
      "!node_modules/@paulcbetts/cld/deps/cld${/*}"
    ]

All 5 comments

Please try to use files to exclude.

Probably !node_modules/@paulcbetts/cld/deps/cld${/*}

@develar yeah I tried files option in my development package.json like this -

"files": [
      "!node_modules/@paulcbetts/cld/deps/cld${/*}"
    ]

but it didn't work -

npm run dist

> [email protected] dist /Users/akka/dev/zulipwork/zulip-electron
> build

Rebuilding native production dependencies for arch x64
Packaging for darwin x64 using electron 1.4.7 to dist/mac
Error: Application entry file "main/index.js" in the "/Users/akka/dev/zulipwork/zulip-electron/dist/mac/Zulip.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
    at error (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/asarUtil.ts:429:12)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/asarUtil.ts:454:11
    at next (native)
    at runCallback (timers.js:570:20)
    at tryOnImmediate (timers.js:550:5)
    at processImmediate [as _immediateCallback] (timers.js:529:5)
From previous event:
    at checkFileInArchive (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/asarUtil.js:104:22)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/platformPackager.ts:393:13
    at next (native)
From previous event:
    at MacPackager.checkFileInPackage (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/platformPackager.js:451:11)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/platformPackager.ts:435:16
From previous event:
    at MacPackager.sanityCheckPackage (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/platformPackager.js:466:11)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/platformPackager.ts:278:16
    at next (native)
    at runCallback (timers.js:570:20)
    at tryOnImmediate (timers.js:550:5)
    at processImmediate [as _immediateCallback] (timers.js:529:5)
From previous event:
    at MacPackager.doPack (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/platformPackager.js:326:11)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/macPackager.ts:79:28
    at next (native)
From previous event:
    at MacPackager.pack (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/macPackager.js:163:11)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/packager.ts:132:22
From previous event:
    at Packager.doBuild (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/packager.js:256:11)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/packager.ts:100:38
    at next (native)
    at runCallback (timers.js:570:20)
    at tryOnImmediate (timers.js:550:5)
    at processImmediate [as _immediateCallback] (timers.js:529:5)
From previous event:
    at Packager.build (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/packager.js:208:11)
    at /Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/src/builder.ts:240:40
    at next (native)
From previous event:
    at build (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/builder.js:89:21)
    at Object.<anonymous> (/Users/akka/dev/zulipwork/zulip-electron/node_modules/electron-builder/out/build-cli.js:62:41)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/akka/.nvm/versions/node/v6.3.1/bin/node" "/Users/akka/.nvm/versions/node/v6.3.1/bin/npm" "run" "dist"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dist: `build`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the [email protected] dist script 'build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the zulip package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs zulip
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls zulip
npm ERR! There is likely additional logging output above.

Am I doing something wrong here? Here is my app structure - zulip-electron

As stated in the docs:

Remember that default pattern /* is not added to your custom, so, you have to add it explicitly — e.g. ["/", "!ignoreMe${/}"].

@develar you're awesome. Thank you so much ❤️ . To make it work correctly I had to use it like this -

"files": [
     "**/*",
      "!node_modules/@paulcbetts/cld/deps/cld${/*}"
    ]

Reopened — not user friendly. If only ignored patterns are specified — obviously all not ignored files must be copied.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AidanNichol picture AidanNichol  ·  3Comments

philcockfield picture philcockfield  ·  3Comments

mstralka picture mstralka  ·  3Comments

lbssousa picture lbssousa  ·  3Comments

jhg picture jhg  ·  3Comments