5

Looking at the package contents of an Electron OSX app, I see that there is a lot of node module cruft included which isn't needed at runtime and which add to app size bloat. For example, that lightgallery "demo" directory, in the first image below, is 1.9 mb.

This makes me wonder if I am doing something wrong with either my package.json file or with my build script:

"package-mac": "electron-packager . --overwrite  --platform=darwin 
--arch=x64  --prune=true --out=release-builds",

Is there any way to get rid of all the extra stuff?


enter image description here


spring
  • 18,009
  • 15
  • 80
  • 160
  • How do you pack the modules? Are you using webpack or something? It's interesting because as much as I know, webpack should includes in the bundle only required modules so probably it shouldn't include even the `node_module` folder itself.. – Mosh Feu Jun 26 '19 at 22:08
  • @MoshFeu - thanks for the comment. Not using Webpack. I am just using `Electron-Builder` which (I guess) uses `Electron-Packager`. I have `prune=true` and `dependencies` & `devdependencies` defined in my `package.json`. Maybe I am doing it wrong? – spring Jun 26 '19 at 22:52
  • 1
    Unfortunately, even though electron-builder filters `devdependencies` and some uneeded files from the packaged app, it doesn't cover everything. Some npm packages contain unneeded images, pdf files and docs which leads to [this](https://pbs.twimg.com/media/DEIV_1XWsAAlY29.jpg?format=jpg&name=orig). I recommend you use a tool like [`modclean`](https://www.npmjs.com/package/modclean) which removes commonly added unnecessary files. – aabuhijleh Jul 01 '19 at 16:24

0 Answers0