Gruntjs Grunt构建:工厂定义上的concat任务存在问题

Gruntjs Grunt构建:工厂定义上的concat任务存在问题,gruntjs,grunt-contrib-concat,Gruntjs,Grunt Contrib Concat,我正在使用yeoman的angular fullstack生成器构建一个应用程序框架 到目前为止,我们在开发版本上的工作没有问题(grunt-service工作没有问题)。现在我们准备进入生产阶段,因此我一直在尝试使用grunt build构建发行版。我们正在使用grunt的版本0.4.5 然而,dist/.tmp/concat/app/中生成的app.js文件包含原始文件中没有的错误 生成所执行的任务由grunfile.js的以下部分确定: grunt.registerTask('build'

我正在使用yeoman的angular fullstack生成器构建一个应用程序框架

到目前为止,我们在开发版本上的工作没有问题(
grunt-service
工作没有问题)。现在我们准备进入生产阶段,因此我一直在尝试使用
grunt build
构建发行版。我们正在使用grunt的版本0.4.5

然而,
dist/.tmp/concat/app/
中生成的
app.js
文件包含原始文件中没有的错误

生成所执行的任务由
grunfile.js
的以下部分确定:

grunt.registerTask('build', [
'clean:dist',
'injector:less', 
'concurrent:dist',
'injector',
'wiredep',
'useminPrepare',
'autoprefixer',
'ngtemplates',
'concat',
'ngAnnotate',
[...]
在构建到达
ngAnnotate
之前,一切正常。当时我得到了以下错误:

error: couldn't process source due to parse error
解析错误的来源来自以下问题

原始的
app.js
包含以下工厂:

.factory('authInterceptor', function ($rootScope, $q, $cookieStore, $location) {
return {
  // Add authorization token to headers
  request: function (config) {
    config.headers = config.headers || {};
    if ($cookieStore.get('token')) {
      config.headers.Authorization = 'Bearer ' + $cookieStore.get('token');
    }
    return config;
  },

  // Intercept 401s and redirect you to login
  responseError: function(response) {
    if(response.status === 401) {
      $location.path('/login');
      // remove any stale tokens
      $cookieStore.remove('token');
      return $q.reject(response);
    }
    else {
      return $q.reject(response);
    }
  }
};
})
但构建的第一步生成的相应代码如下所示:

(function() {

function authInterceptor($rootScope, $q, $cookies, $location, Util) {
  return {
    // Add authorization token to headers
    request(config) {
      config.headers = config.headers || {};
      if ($cookies.get('token') && Util.isSameOrigin(config.url)) {
        config.headers.Authorization = 'Bearer ' + $cookies.get('token');
      }
      return config;
      },

   // Intercept 401s and redirect you to login
   responseError(response) {
       if (response.status === 401) {
        $location.path('/login');
        // remove any stale tokens
        $cookies.remove('token');
       }
       return $q.reject(response);
    }
  };
}

angular.module('insuranceAppApp.auth')
  .factory('authInterceptor', authInterceptor);

})();
我已经尝试了一段时间来理解构建的错误之处。但我对咕噜声完全是个初学者

有没有人遇到过类似的问题? 有人知道问题的根源是什么吗