Electron build size 2.1GB

Viewed 572

I am trying to build an electron app with some functionality.But it size becomes 2.1 GB when i build an app using npx electron - builder.

I have modified my package to remove unused dependencies.But did not get any luck. I also used "compression":"maximum" but it only increase the size but no luck

const axios = require('axios');
var fs = require('fs');

const BrowserWindow = electron.BrowserWindow
let win;
function createWindow() {
    //create window with some context-menus
}

app.on("ready", createWindow);
app.on("window-all-closed", () => {
    if (process.platform !== "darwin") {
        app.quit();
    }
});
app.on("activate", () => {
    if (win === null) {
        createWindow();//Create window
    }
});

ipcMain.on('getFiles', async(event, arg) => {
    //check file and read its content
        win.webContents.send("getFilesResponse", JSON.parse(fileData.toString()));
    } else {
          //get makeaddress and send this random string to node server. It will return some data and save it to file on local machine. Return the response.  
          win.webContents.send("getFilesResponse", response.data.data);
        } catch (err) {}

    }
});
function makeaddress(length, type = 'random') {
   return some-random-string;
}
Size should not be greater than 200 MB.
1 Answers

Just putting it here in case someone is confused like me.

I faced the same incident today. Later I realized that I was not excluding the release-builds folder created by electron-packager that I have used before to package my app. Maybe you also have some other large folders/files inside project directory that doesn't need to be included.

To exclude the files, use glob patterns as follows in package.json:

...
"build": {
    ...
    "files": [
        "!release-builds",
        "!test.*",
        ... 
    ]
}

Docs: https://www.electron.build/configuration/contents#files

Related