Arun Krishnan
Arun Krishnan

Reputation: 271

electron builder app size is too large

I find that the MyApp.exe file generated using electron-builder is nearly about 500M. I am not sure what I did because previously, just for ia32 or x64, it would be around 196M. I also looked at this link and it mentions only about 55MB-60MB. So the question is, why am I getting such large sizes for my exe files? My app itself is very small and if electron is only around 33MB, what's all that extra space there?

Here are my package.json entries:

"build": {
"appId": "com.electron.myApp",
"publish": [
  {
    "provider": "generic",
    "url": "https://myAppServer"
  }
],
"win": {
  "target": [
    {
      "target": "nsis",
      "arch": [
        "ia32"
      ]
    }
  ]
},
"asar": false,
"nsis": {
  "oneClick": true,
  "perMachine": false,
  "artifactName": "${productName}-Setup-${version}.${ext}"

}    
"devDependencies": {
 "electron": "^1.7.9",
 "electron-installer-windows": "^0.2.0",
 "electron-builder": "^19.45.5",
 "electron-packager": "^8.5.2",
 "electron-winstaller": "^2.5.2",
 "grunt-electron-installer": "^2.1.0"
},
"dependencies": {
 "auto-launch": "^5.0.1",
 "cron": "^1.2.1",
 "electron-config": "^0.2.1",
 "electron-positioner": "^3.0.0",
 "electron-squirrel-startup": "^1.0.0",
 "electron-window": "^0.8.1",
 "electron-updater": "^2.16.1",
 "fs": "^0.0.1",
 "homedir": "^0.6.0",
 "https": "^1.0.0",
 "https-proxy-agent": "^1.0.0",
 "line-by-line": "^0.1.5",
 "pac-proxy-agent": "^1.0.0",
 "url": "^0.11.0",
 "winreg": "^1.2.3",
 "xml2js": "^0.4.17"
} 
}

Is this the expected size of an electron app? Any way to make this smaller?

Regards, Arun

Upvotes: 11

Views: 12862

Answers (3)

Franco
Franco

Reputation: 868

You should tell electron builder to only use your built files which was generated by

ng build --configuration production

To do this use the files parameter inside your build parameter in your package.json:

"files": [
        "!*.*",
        "!**/*",
        "dist/YourApp/**/*"
    ],
  • The 1st value exludes all files in root directory of your project
  • The 2nd value exludes all subdirectories in root directory of your project
  • List 3rd value only includes your built code

Upvotes: 0

Peter Jaric
Peter Jaric

Reputation: 5302

I'm going to turn Arun's comment into an answer because I nearly missed it, and it was what solved the issue for me:

I figured out what the issue was. I had an Output directory within my electron root directory where I was storing my final MSI files. It was packaging that directory as well as a result of which the size kept growing.

Thanks, Arun!

Upvotes: 2

Mert Simsek
Mert Simsek

Reputation: 1560

You can try npm prune --production but even the most minimal Electron application is going to be around 100MB.

Upvotes: 11

Related Questions