Tasks for production prepared Ionic app

703 views Asked by At

I'm trying to figure out what's the best process to pass from the code to the final deployable apk/ipa.

So far I have a testsuite using Karma + Jasmine, which transpiles the TypeScript to JS and runs some unit tests. I start that process via gulp.

After that all I know is to ionic build android --release what generates (an unsigned yet) apk. But I'm not sure of how ofuscated/minificated the generated apk is.

So, keeping in mind the code has to be as private as possible, is the minification and the ofuscation of the ionic build enough or should I do all those prebuild tasks manually via gulp? And in that case, whats are the right tasks I should run, do I have to transpile all the TypeScript files to JS manually? and in what order should I run the tasks?

E.g. transpile -> tests -> minify -> uglify -> build apk or minify -> uglify -> transpile -> tests -> build apk

I'm a bit lost with this, and the only thing I can figure out is that the tests should be ran first, because is case of test failure the process should be aborted.

2

There are 2 answers

1
Faria On

Try ionic-app-scripts >= 0.0.48 to config build.

Production:

ionic build android --prod

To check the minified file, open the apk file with GNOME Archive Manager (or similiar) and extract /assets/www/build/js/app.bundle.js file.

0
maninak On

Preparing an Ionic Cordova app for release in production

1. Building

In your terminal execute the following command according to your platform (android / ios):

ionic build android --prod --release

2. Releasing

In order to be able to install a production application on a device and furthermore in order to be able to publish it in app stores, your .apk or .ipa file needs to be signed. How you do that depends on the platform.

Here is the procedure in detail for Android and for iOS.


Preparing an Ionic Progressive Web App (PWA) for release in production

1. Building

In your package.json file, you should make sure to have something like the following:

"scripts": {
     // ...
     "build:www": "rm -rf www && ionic-app-scripts build --prod",
     // ...
},

Now in your terminal run:

npm run build:www

2. Releasing

Your app is built in the folder www ready for you to serve in production using any webserver like NginX, Apache or a custom Node + Express webserver.


Valid as of Ionic v3.3

Learn more about ionic-scripts, what they do and which other scripts you could possibly find useful.