When trying to use gulp-ugily with my angular application, it is breaking, even though I am running it through gulp-ngmin.
Here is the gulp file:
var gulp = require('gulp'),
    concat = require('gulp-concat'),
    ngmin = require('gulp-ngmin'),
    uglify = require('gulp-uglify');
gulp.task('compress', function() {
    gulp.src('client/js/source/*.js')
        .pipe(concat('app.js'))
        .pipe(ngmin())
        .pipe(uglify())
        .pipe(gulp.dest('client/js'));
});
                It helps to disable the mangle option in uglify, for it's messing with all the injection stuff and naming.
.pipe(uglify({ mangle: false }))
                        Maybe answering this for future users, as it seems the post is old.
Use ng-annotate to fix AngularJS problems when uglifying. Install it as any other library:
npm install gulp-ng-annotate --save-dev
And then use this in your gulpfile.js:
var gulp = require('gulp')
var concat = require('gulp-concat')
var uglify = require('gulp-uglify')
var ngAnnotate = require('gulp-ng-annotate')
gulp.task('js', function () {
  gulp.src(['src/**/module.js', 'src/**/*.js'])
    .pipe(concat('app.js'))
    .pipe(ngAnnotate())
    .pipe(uglify())
    .pipe(gulp.dest('.'))
})
Hope this helped!
Source: https://medium.com/@dickeyxxx/best-practices-for-building-angular-js-apps-266c1a4a6917
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With