我无法说服为什么uglify不能用于我的app.js(angularjs)文件。这是我的js文件的一部分。
(function() {
'use strict';
var coursesApp = angular.module('pwaCoursesApp',['ngRoute', 'ngSanitize'])
coursesApp.config(['$routeProvider', '$locationProvider', function( $routeProvider, $locationProvider){
$routeProvider
.when('/',
{
templateUrl: '/home.html',
controllerAs: 'homeCtrl'
})
.otherwise({redirectTo:'/'});
}]);
coursesApp.controller('homeCtrl', function($scope, $http) {
});
})();
这是我的gulp uglify脚本
gulp.task('scripts', function() {
var sources = [
'node_modules/es6-promise/dist/es6-promise.js',
'app/scripts/app.js',
];
return gulp.src(sources)
.pipe($.concat('main.min.js'))
.pipe($.uglify())
.pipe(gulp.dest('dist/scripts'))
.pipe($.size({title: 'scripts'}));
});
并且gulp告诉我它已成功uglify但是当我渲染我的应用程序时它根本不起作用并向我显示该错误消息。
main.min.js:2 Error: [$injector:unpr] http://errors.angularjs.org/1.3.8/$injector/unpr?p0=tProvider%20%3C-%20t%20%3C-%20homeCtrl
at http://localhost:3000/scripts/main.min.js:1:6739
at http://localhost:3000/scripts/main.min.js:1:22851
at Object.r [as get] (http://localhost:3000/scripts/main.min.js:1:21847)
at http://localhost:3000/scripts/main.min.js:1:22924
at r (http://localhost:3000/scripts/main.min.js:1:21847)
at Object.i [as invoke] (http://localhost:3000/scripts/main.min.js:1:22103)
at l.instance (http://localhost:3000/scripts/main.min.js:2:10025)
at http://localhost:3000/scripts/main.min.js:2:1403
at o (http://localhost:3000/scripts/main.min.js:1:7233)
at x (http://localhost:3000/scripts/main.min.js:2:1387) <div ng-view="" class="ng-scope">
但不是uglify,它运作顺利。请让我知道我错过了什么。感谢。