Reputation: 862
I'm trying to find out if smaller file size is possible, to have distributable one file for Express based API server app with some trayicon for basic controls - basically exit + restart app + open the API in default browser.
With Electron Builder I can do --ia32 target in about 68MB, but wonder if any lower size is possible, to learn more about it. But was having problem trying to get Systray2 and related solutions working using pkg (getting ENONENT on the exe file from node_modules (yes, tried adding it to package.json pkg assets, or even copied that exe to traybin folder under project root). I am sure there is a way but I may be missing something maybe obvious, so ready made Git would be great.
So if anything handy possible, is there some boilerplate ready to download? It just feels like waste of space to download Electron, when I only use the builder, Tray & Notification, but no mainWindow, ipc Renderer etc...
Upvotes: 0
Views: 936
Reputation: 131
Not sure if this is relevant for you still, but I actually ran across the exact same requirement today. After many trials & errors, I did manage to solve it simply by setting the copyDir
flag to true
as shown in the below code when using the systray2 npm package:
const systray = new SysTray({
menu: {
icon: os.platform() === 'win32' ? './logo_s.ico' : './logo_s.png',
isTemplateIcon: os.platform() === 'darwin',
title: 'App',
tooltip: 'App',
items: [
itemExit
]
},
debug: false,
copyDir: true // This makes the systray2 work with pkg
})
My win-x64 binary size ended up at 38MB
with Brotli compression (fastify server + systray2 + some css/images/js).
I didn't compare it with Electron Builder though, but I have a hunch it would be larger than that :)
Upvotes: 1