I wish to now build and distribute the app built with Ionic. However, re-initialising console.log()
's is not producing the desired effect.
I have tried to reinit console.log function but there are still logs in my application.
var console = {};
console.log = function(){};
window.console = console;
You could use Gulp to accomplish this.
gulp-strip-debug is a gulp plugin which strips all console.log()'s, console.info(), debugger,... statements.
Here's an example how your gulpfile.js
should look like:
var gulp = require('gulp');
var stripDebug = require('gulp-strip-debug');
gulp.task('strip-debug', function () {
// Build location folder
// Strip stuff in these files.
return gulp.src('src/js/*')
.pipe(stripDebug())
// Location output of the 'stripped' files
// In your case, this should be the same as your build destination
.pipe(gulp.dest('dist/js/'));
});
One way to do this is to remove the cordova console plugin before publishing.
$ cordova plugin rm cordova-plugin-console
reference: http://ionicframework.com/docs/guide/publishing.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.