Javascript 格伦特如何缩小或丑化生活?
在标准的Javascript 格伦特如何缩小或丑化生活?,javascript,angularjs,gruntjs,iife,Javascript,Angularjs,Gruntjs,Iife,在标准的咕噜服务中我在我的一条指令周围使用IIFE,如下所示: (function() { "use strict"; angular.module('napiRest') .directive('componentStaffReport', ['$modal', 'ComponentStaffFactory', function ($modal, ComponentStaffFactory) { return { restrict: 'E'
咕噜服务中
我在我的一条指令周围使用IIFE,如下所示:
(function() {
"use strict";
angular.module('napiRest')
.directive('componentStaffReport', ['$modal', 'ComponentStaffFactory', function ($modal, ComponentStaffFactory) {
return {
restrict: 'E',
transclude: true,
scope: {
componentId: '=componentId',
linkableContent: '=linkableContent'
},
templateUrl: 'app/pages/report/component-staff/component-staff-popup.html',
link: function (scope, element, attr) {
ComponentStaffFactory.componentId = scope.componentId;
var modalInstance = null;
scope.open = function () {
modalInstance = $modal.open({
templateUrl: 'ComponentStaffModal.html',
controller: 'ComponentStaffingCtrl',
size: 'lg',
backdrop: true,
windowClass: 'x-x-large-modal'
});
ComponentStaffFactory.modalInstance = modalInstance;
};
} //link
}; //return
}])
})();
当我使用grunt-service:dist部署时,这不起作用。我得到错误:uncaughttypeerror:对象不是函数
然而,当我移除周围的生命时,它不会出错。这是不是因为grunt for dist中的丑陋或缩小方式造成的?问题似乎是由于另一个文件中缺少分号造成的。另一个文件是一个角度控制器,末尾没有分号。当grunt丑化代码时,它将这个文件和上面的文件混合在一起,创建自己的匿名函数,这当然是编译器不喜欢的 你用什么插件来缩小你的代码?你有没有试过查看缩小代码的部分,看看到底是什么导致了错误?grunt不会自己缩小任何东西。