Gulp ngmin + uglify no funciona correctamente


Tengo la siguiente tarea:

gulp.task('scripts', function() {
return gulp.src(['app/js/app.js', 'app/config/config.js', 'app/js/controllers.js', 'app/js/directives.js' , 'app/js/filters.js',  'app/js/footer.js',
                 'app/js/guideTour.js', 'app/js/mobileBanner.js', 'app/js/services.js', 'app/js/youtube.js', 'app/js/dataSync.js', 'app/js/addthis.js'])
//.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(ngmin())
.pipe(gulp.dest('app/dist/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('app/dist/js'))
.pipe(livereload(server))
.pipe(notify({ message: 'Scripts task complete' }));
});

El problema es que el archivo concatenado que también es la salida de ngmin(), está funcionando bien, pero después de uglificar el código, algo se rompe, y obtengo el siguiente error.

Sin un indicador específico de dónde iniciar la depuración.

Seguimiento de pila:

Error: [$injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=eProvider%20%3C-%20e
at Error (native)
at http://localhost:8000/angular/angular.min.js:6:449
at http://localhost:8000/angular/angular.min.js:32:125
at Object.c [as get] (http://localhost:8000/angular/angular.min.js:30:200)
at http://localhost:8000/angular/angular.min.js:32:193
at c (http://localhost:8000/angular/angular.min.js:30:200)
at Object.d [as invoke] (http://localhost:8000/angular/angular.min.js:30:417)
at http://localhost:8000/angular/angular-route.min.js:10:302
at Object.q [as forEach] (http://localhost:8000/angular/angular.min.js:7:380)
at http://localhost:8000/angular/angular-route.min.js:10:248 
Author: Cœur, 2014-02-23

2 answers

La solución estaba ejecutando la tarea uglify con la opción mangle establecida en false. ie: .uglify({mangle: false})

Código completo:

gulp.task('scripts', function() { 
return gulp.src('app/js/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(ngmin())
.pipe(gulp.dest('app/dist/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('app/dist/js'))
.pipe(livereload(server))
.pipe(notify({ message: 'Scripts task complete' }));
});
 54
Author: Oleg Belousov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-02-23 15:28:57

No necesita establecer mangle en false, solo puede usar ng-annotate y llamar a su gulpfile.js como esto:

var ngAnnotate = require('gulp-ng-annotate')
...
gulp.task('scripts', function() { 
return gulp.src('app/js/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(ngmin())
.pipe(gulp.dest('app/dist/js'))
.pipe(rename({suffix: '.min'}))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest('app/dist/js'))
.pipe(livereload(server))
.pipe(notify({ message: 'Scripts task complete' }));
});

Funciona en mis proyectos para app en un solo archivo

 10
Author: Guilherme Lima Conceição,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-09 02:51:27