avn
avn

Reputation: 832

Electron + Angular CLI how to package dist with electron-packager

I have an Electron and Anguarjs CLI app that I want to distribute.

After running ng build --prod I get a dist directory that is ~1Mb. However after running electron-packager . the app is ~350Mb.

I have my electron main.js setup to point to the index.html of the dist, but I am guessing that the package command doesn't use the dist to build the app but rather the bloated dev version. I have tried running electron-packager . from within dist, it still creates a huge app.

Is there a way to package the dist folder? Should I rather be using a different packaging tool?

My aim is to package the app so that doesn't nuke band width to distribute.

Upvotes: 2

Views: 2927

Answers (1)

rob3c
rob3c

Reputation: 2086

From the electron-packager readme.md:

Be careful not to include node_modules you don't want into your final app. If you put them in the devDependencies section of package.json, by default none of the modules related to those dependencies will be copied in the app bundles.

The angular CLI uses webpack internally to bundle your code. To reduce the electron package size, whatever is already bundled by webpack that's currently in your dependencies section of your package.json can go in the devDependencies section instead. That'll prevent electron-packager from bundling any node_modules code you aren't actually referencing due to webpack having already extracted it when bundling the output chunks in your dist folder.

Upvotes: 1

Related Questions