peterjc
February 11, 2017, 6:20am
1
Hi, I just run the command ionic build android --release
which output the file android-release-unsigned.apk
. I opened this up (using 7zip) and as far as I can tell, at least my own code does not appear to be minified (looking into main.js), it has all the comments, spaces and full variable names etc in there.
Should this be part of the stock build process? ionic --version
gives me 2.2.1.
Thanks in advance!
Daskus
February 11, 2017, 8:02am
2
You need to run the command with --prod
.
ionic build android --prod --release
1 Like
peterjc:
se which output the file android-release-unsigned.apk. I opened this up (using 7zip) and as far as I can tell, at least my own code does not appear to be minified (looking into main.js), it has all the comments, spaces and full variable names etc in there.
It’s not cordova’s job to do that. Use a build tool like weback or gulp. Gulp is pretty simple to setup. You can start with gulp uglify plugin.
var gulp = require('gulp');
var gutil = require('gulp-util');
// Reused
var concat = require('gulp-concat');
//JS
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var stripDebug = require('gulp-strip-debug');
gulp.task('js', function(){
return gulp.src("arrayOfFilePathsToYourJSFiles")
.pipe(concat('all.js'))
.pipe(ngAnnotate())
.pipe(uglify({mangle: false}))
.pipe(stripDebug())
.pipe(gulp.dest('./www/src/'))
});
peterjc
February 11, 2017, 10:13am
4
Thanks that did the trick… Interesting the .map file is included. I wonder if that is needed, and if that can be removed.
.map file should be removed for production, as it is only needed for development purposes.