electron-react-ts
electron-react-ts copied to clipboard
Build size
I like how minimal this repo is, when compared to something like https://github.com/electron-react-boilerplate/electron-react-boilerplate, however the build size is a real issue.
My builds are sitting at 500mb from a fresh clone, do you have any suggestions on reducing? It seems the main problem is that we're including all node_modules into the production builds that electron-builder is creating?.
@TomYeoman
500MB? That's weird. I think something is going wrong in your environment. Here is the result of the build at hand:
on macOS:
% ls -lh release
total 340376
-rw-r--r--@ 1 82M 8 30 06:20 Electron App-1.9.8-darwin-arm64.dmg
-rw-r--r-- 1 88K 8 30 06:20 Electron App-1.9.8-darwin-arm64.dmg.blockmap
-rw-r--r-- 1 79M 8 30 06:20 Electron App-1.9.8-darwin-arm64.zip
-rw-r--r-- 1 85K 8 30 06:20 Electron App-1.9.8-darwin-arm64.zip.blockmap
-rw-r--r-- 1 732B 8 30 06:20 builder-debug.yml
-rw-r--r-- 1 406B 8 30 06:20 builder-effective-config.yaml
-rw-r--r-- 1 531B 8 30 06:20 latest-mac.yml
drwxr-xr-x 3 96B 8 30 06:20 mac-arm64/
on Ubuntu Linux:
% ls -lh release
total 163M
-rw-r--r-- 75M Aug 30 06:29 'Electron App-1.9.8-linux-amd64.snap'
-rwxr-xr-x 88M Aug 30 06:28 'Electron App-1.9.8-linux-x86_64.AppImage'*
-rw-rw-r-- 730 Aug 30 06:29 builder-debug.yml
-rw-rw-r-- 406 Aug 30 06:28 builder-effective-config.yaml
-rw-rw-r-- 400 Aug 30 06:29 latest-linux.yml
drwxrwxr-x 4.0K Aug 30 06:28 linux-unpacked/
we're including all
node_modulesinto the production builds that electron-builder is creating
electron-builder should have includeSubNodeModules set to false by default.
Could you check your builder.ts again?
build({
config: {
files: ['dist/**/*'],
},
});
And generally speaking, the only way to reduce the size of a production build is to remove unnecessary packages up front.
{
"scripts": {
"prebuild": "npm r rimraf wait-on --no-save"
}
}
I recommend using ifdef-loader for further weight loss.
And also on Windows 11:
$ npm run build && npm run package
$ ls -lh release
total 154M
-rwxr-xr-x 1 65M Aug 30 09:57 'Electron App-1.9.8-installer.exe'*
-rw-r--r-- 1 71K Aug 30 09:57 'Electron App-1.9.8-installer.exe.blockmap'
-rw-r--r-- 1 89M Aug 30 09:57 'Electron App-1.9.8-win32-x64.zip'
-rw-r--r-- 1 6.8K Aug 30 09:57 builder-debug.yml
-rw-r--r-- 1 406 Aug 30 09:56 builder-effective-config.yaml
-rw-r--r-- 1 360 Aug 30 09:57 latest.yml
drwxr-xr-x 1 0 Aug 30 09:56 win-unpacked/
I would like you to try my other boiler plate if you like.