angularjs – Gulp ngmin uglify无法正常工作

前端之家收集整理的这篇文章主要介绍了angularjs – Gulp ngmin uglify无法正常工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下gulp任务:
  1. gulp.task('scripts',function() {
  2. 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'])
  3. //.pipe(jshint('.jshintrc'))
  4. .pipe(jshint.reporter('default'))
  5. .pipe(concat('main.js'))
  6. .pipe(ngmin())
  7. .pipe(gulp.dest('app/dist/js'))
  8. .pipe(rename({suffix: '.min'}))
  9. .pipe(uglify())
  10. .pipe(gulp.dest('app/dist/js'))
  11. .pipe(livereload(server))
  12. .pipe(notify({ message: 'Scripts task complete' }));
  13. });

问题是连接文件也是ngmin()的输出,工作正常,但是在解密代码后,某些东西中断了,我得到了following error

没有具体的指标从哪里开始调试。

堆栈跟踪:

  1. Error: [$injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=eProvider%20%3C-%20e
  2. at Error (native)
  3. at http://localhost:8000/angular/angular.min.js:6:449
  4. at http://localhost:8000/angular/angular.min.js:32:125
  5. at Object.c [as get] (http://localhost:8000/angular/angular.min.js:30:200)
  6. at http://localhost:8000/angular/angular.min.js:32:193
  7. at c (http://localhost:8000/angular/angular.min.js:30:200)
  8. at Object.d [as invoke] (http://localhost:8000/angular/angular.min.js:30:417)
  9. at http://localhost:8000/angular/angular-route.min.js:10:302
  10. at Object.q [as forEach] (http://localhost:8000/angular/angular.min.js:7:380)
  11. at http://localhost:8000/angular/angular-route.min.js:10:248
解决方案是运行uglify任务,将 mangle选项设置为false。
即:.uglify({mangle:false})

整码:

  1. gulp.task('scripts',function() {
  2. return gulp.src('app/js/**/*.js')
  3. .pipe(jshint('.jshintrc'))
  4. .pipe(jshint.reporter('default'))
  5. .pipe(concat('main.js'))
  6. .pipe(ngmin())
  7. .pipe(gulp.dest('app/dist/js'))
  8. .pipe(rename({suffix: '.min'}))
  9. .pipe(uglify({mangle: false}))
  10. .pipe(gulp.dest('app/dist/js'))
  11. .pipe(livereload(server))
  12. .pipe(notify({ message: 'Scripts task complete' }));
  13. });

猜你在找的Angularjs相关文章