提供者依赖注入& uglify特例

时间:2013-04-29 10:29:35

标签: angularjs uglifyjs

我使用了angular-app中的安全功能,并且在authorizationProvider中有一些时髦的东西

angular.module('security.authorization', ['security.service'])

// You can add them as resolves to routes to require authorization levels
// before allowing a route change to complete
.provider('securityAuthorization', {

  requireUser: ['securityAuthorization', function(securityAuthorization) {
    return securityAuthorization.requireUser();
  }],

  $get: ['security', 'securityRetryQueue', function(security, queue) {
    var service = {

      requireUser: function() {
        //Stuff ...
        return true;
    };

    return service;
  }]
});

提供者将自身注入属性'requireUser',该属性调用$ get factory方法返回的函数。现在,当我尝试对此进行uglify(grunt-contrib-uglify)时,它失败了

  requireUser: ['securityAuthorization', function(securityAuthorization) {
    return securityAuthorization.requireUser();
  }]

Unknown provider: eProvider <- e。我怎样才能缩小这个?我已经尝试了替代提供程序声明(从1.1.x开始,可以像普通工厂一样声明提供程序,即注入依赖项并让提供程序成为函数),但这也不起作用,因为它查找依赖项security.authorization模块。

1 个答案:

答案 0 :(得分:4)

grunt-contrib-uglify的一个选项是mangle

尝试将此添加到您的Uglify配置中:

uglify: {
  options: {
    mangle: false
  }
}