Make electron app smaller?

谁说胖子不能爱 提交于 2019-12-04 11:03:40

问题


I just recently built an electron app and packaged it using electron-packager. The .exe file is 55,000kb and the rest of the folder is quite bulky as well. Is there any way to take down the size of this application at all?


回答1:


Here's a github issue on it.

The comment I'm emphasizing is:

That's the expected size, there is no way to make it smaller.

The reason why it's so big is because electron is loading most of chromium inside that 50mb file.

So no unfortunately there is no way to make it smaller sorry.




回答2:


A somewhat helpful post from that github thread suggests removing unnecessary node modules via electron-packager. It also offers a bit more explanation on why files are so large.

You can zip your app and if you're using electron-packager you can ignore some node modules that you don't need when the app is running, this makes it a bit smaller. For instance I have a 37MB zipped Electron app (Note Windows version is much larger as it contains a copy of Git). But Electron will always have a large part of Chrome in it so there is only so much that can be done. Electron itself right now is ~33MB.




回答3:


There is a way to reduce Electron size drastically (up to 99%, depending how big is your app), by using native browser, available in each OS, instead of loading webkit. BUT as built in browsers don't have the system API's, you will also be drastically limited in what you can do. But, if you need basic web ui app, this might be the best solution out there, though, it must be mentioned, that it might have some unexpected issues, as you will need to test your app on different OS'es browsers..

The method i'm talking about is available in awesome post Put your Electron app on a diet with Electrino by Pauli Olavi Ojala



来源:https://stackoverflow.com/questions/47310947/make-electron-app-smaller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!