2014-02-23 6 views
23

Ich habe folgende schluck Aufgabe:Gulp ngmin + verunstalten nicht ordnungsgemäß funktioniert

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' })); 
}); 

Das Problem ist, dass die verketteten Datei, die auch die Ausgabe von ngmin ist(), fein arbeitet, aber nach uglifying den Code , etwas bricht, und ich bekomme die following error.

Mit keinem bestimmten Indikator, wo Debuggen zu starten.

Stapelüberwachung:

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 
+0

Sehen Sie sich https://docs.angularjs.org/tutorial/step_05 – cheziHoyzer

Antwort

54

Lösung lief uglify Aufgabe mit mangle Option auf false gesetzt. dh: .uglify({mangle: false})

ganze Code:

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' })); 
}); 
+0

http://stackoverflow.com/quest ionen/23549029/eckig-js-injectionormodulerr-failed-instanziieren-modul-mit-mangle/23762068 # 23762068 – Harry

+1

Mein einziges Problem mit diesem ist, dass ich speziell einstellen muss, um nicht die Hauptfabrik und Modulnamen in eckigen aber zu magen noch immer alle Bower-Skripte. Ich sehe keine Möglichkeit, zu spezifizieren, was zu verfälschen ist und was nicht, ohne eine neue Aufgabe schreiben zu müssen, eine für die Bower-Komponenten und eine für jedes andere Skript. –

+0

awesome Job Kumpel, es funktioniert wirklich für mich! –

10

Sie don `t mangle auf false setzen müssen, die Sie gerade ng-annotate und rufen Sie auf Ihrem gulpfile.js wie diese verwenden:

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' })); 
}); 

funktioniert auf meine Projekte für App in einer einzigen Datei

Verwandte Themen