9

I'm using electron-packager for creating an electron.exe of my app. I need to exclude all node modules . I tried the following

--ignore=node_modules

The above is not working. Any idea how to exclude all folders/ remove node modules in final build.

frogatto
  • 28,539
  • 11
  • 83
  • 129
arun thatham
  • 500
  • 1
  • 4
  • 13
  • I recommend using either electron-forge https://www.npmjs.com/package/electron-forge or electron-builder https://github.com/electron-userland/electron-builder to make your life easy. Unless you have a very special use case those packages will make things easier and faster. – limoragni Mar 23 '18 at 09:44
  • 1
    I highly discourage the use of electron-forge because the dependencies to electron-compile and electron-packer. Both are very flawed especially electron-compile (outated transpilers, flawed path handling for scss and the list goes on). electron-builder on the other hand is the right tool, it will exclude all devDependencies from the "release" node modules. – Hans Koch Mar 23 '18 at 10:03
  • `electron-forge` uses `electron-packager` to do its packaging anyway – Tim Mar 23 '18 at 18:27

1 Answers1

21

If you install modules as devDependencies, they will all be pruned automatically before packaging.

If you're using electron-builder you can define glob patterns as files in the config. In this case !**/node_modules/* will exclude all of node_modules.

If you're using electron-packager you can use the ignore option and regular expression to exclude files.

Joel Briggs
  • 1,779
  • 2
  • 14
  • 17
Tim
  • 7,746
  • 3
  • 49
  • 83