Daniel Stephens
Daniel Stephens

Reputation: 3219

How do I reduce the app size of an Electron app?

I use the latest Electron version 10.0.3 and created a target for app and mas (mac-app-store) and I struggle with the size of the app it created.

I found already a few blog posts which cover the topics, but my app size is so unusually high, that I couldn't pinpoint the cause for my situation.

Here is a list of the sizes:

target: app

target: mas:

Please note, that in the mas build the app.asar is double the size. First I assumed it now also compiles for the new arm64 architecture, but it's just the x86_64. What could be the reason for these huge app sizes, and why is mas double the size?

Upvotes: 2

Views: 1849

Answers (1)

aabuhijleh
aabuhijleh

Reputation: 2464

The big size of the asar archive is most likely related to the node modules you are using

You can extract app.asar like this

npx asar extract app.asar dest

Then you can use a tool like WinDirStat on the extracted folder to determine the guiltiest modules and you can perhaps remove or replace them

You can also use modclean before packaging to delete unneeded junk that sometimes is included in some modules

Also, make sure to install modules that are only needed in development as devDependencies so that electron-builder won't package them. electron for example, should be in devDependencies

Upvotes: 3

Related Questions