Closed sajjadmrx closed 1 year ago
I used
electron-builder
instead ofelectron-forge
and I did following tricks to reduce size:
- The reason of this problem is, when you package the software, all packages (like redux, react ...) in
node_modules
is included in installer exe. The solution is to devide your software in two section (or project). elecron part and react part. and delete all front packages from electron relatedpackage.json
file. And then build your react and put production code it electron app.- Add
"afterPack": "./utils/removeLocales.js"
to delete all extra locales."build": { "appId": "com.electron.electron-serial", "productName": "electron-serial", "afterPack": "./utils/removeLocales.js",
removeLocales.js:
//https://www.electron.build/configuration/configuration#afterpack exports.default = async function(context) { //console.log(context) var fs = require('fs'); var localeDir = context.appOutDir+'/locales/'; fs.readdir(localeDir, function(err, files){ //files is array of filenames (basename form) if(!(files && files.length)) return; for (var i = 0, len = files.length; i < len; i++) { var match = files[i].match(/en-US\.pak/); if(match === null){ fs.unlinkSync(localeDir+files[i]); } } }); }
hey, What was the output size? and can you send pull request?
I got 70 mb for windows .msi
file (I think it's normal for electron app).
I do not have exprience with electron-forge
as it uses very specific starter boilerplate.
I used
electron-builder
instead ofelectron-forge
and I did following tricks to reduce size:The reason of this problem is, when you package the software, all packages (like redux, react ...) in
node_modules
is included in installer exe. The solution is to devide your software in two section (or project). elecron part and react part. and delete all front packages from electron relatedpackage.json
file. And then build your react and put production code it electron app.Add
"afterPack": "./utils/removeLocales.js"
to delete all extra locales.removeLocales.js: