adopted-ember-addons / ember-electron

:zap: Build, test, compile and package desktop apps with Ember and Electron
https://ember-electron.js.org/
Other
805 stars 109 forks source link

The option '--ignore' is not registered with the electron:package command. #305

Closed edmoresamewave closed 7 years ago

edmoresamewave commented 7 years ago

I am trying to exclude the node_modules folder from being packaged with my app, as it is making it way too large.

Googling for solutions and such points to the use of the --ignore option which seems not to be working:

https://devhub.io/repos/felixrieseberg-ember-electron

How can I exclude the node_modules directory?

edmoresamewave commented 7 years ago

Further research has led me to this:

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. (This behavior can be turned off with the --no-prune flag.)

We have a lot of dependencies, and it seems only those that are in devDependencies are being excluded. So my question should be, is it possible to package an ember electron app without including the node_modules?, does ember-electron have such an option, or the only option is to comb through our dependencies and see the ones we can move to the devDependencies section, if any.

bendemboski commented 7 years ago

Yes, that is the only option. Curious -- why would you have a package in your dependencies if you don't want it included in your app at runtime? That's what the dependencies section is for...

edmoresamewave commented 7 years ago

thanks @bendemboski It is a hybrid application so some of the dependencies may not be necessary to run the app on desktop, i.e. they may be mobile specific for instance.

bendemboski commented 7 years ago

I see. Actually, I think there may be a couple more potential options. ember-electron is built on top of electron-forge, which uses electron-packager.

electron-packager supports an afterPrune option that you could probably implement to delete all the modules you don't want. To do that, you'd put it in the electronPackagerConfig object in your ember-electron/electron-forge-config.js.

Another option would be to look into electron-forge's hooks (implemented here, but not well documented to my knowledge). For example, if you implemented the prePackage hook, you might be able to find the package.json that was copied into the build path here and replace the dependencies hash with one that only contains the dependencies that you want.

bendemboski commented 7 years ago

In any case, I'm going to close out this issue.

edmoresamewave commented 7 years ago

thanks.