我试图使用Webpack捆绑一个Angular应用程序,并在捆绑缩小后遇到问题.此语法具有依赖项的手动注释,可用于:
var app = angular.module('app',[ 'ui.router' ]) .config(['$locationProvider','$stateProvider',($locationProvider,$stateProvider) => { $locationProvider.html5Mode(true); $stateProvider .state('root',{ url: '/',views: { '': { template: '<p>Hello!</p>' } } }); }]);
而此语法产生$injector:modulerr错误:
var app = angular.module('app',[ 'ui.router' ]) .config(($locationProvider,views: { '': { template: '<p>Hello!</p>' } } }); });
我正在为Webpack使用ng-annotate-loader.以下是配置文件的相关部分:
module: { loaders: [ { test: /\.js$/,exclude: /node_modules/,loader: 'ng-annotate!babel?stage=1' },
但这并不能解决[$injector:modulerr]错误.试图改变加载器:’ng-annotate!babel?stage = 1’与加载器的行:[‘ng-annotate’,’babel?stage = 1′],没有任何改进.你能建议我怎么解决它吗?
编辑:最终发现我的问题基本上是Angular ng annotate does not work with babel的重复
EDIT2:有人指出ng-annotate无法注释角度模块的.config,因为我将angular作为es6模块导入而不是将其声明为变量,这显然混淆了ng-annotate.