[英]webpack config for js with ng-annotate-loader & babel-loader
我已經嘗試了兩種方法來同時為我的* .js文件使用ng-annotate和babel加載程序。
{ //this worked
test: /\.js?$/,
loader: 'ng-annotate!babel?presets[]=es2015'
}
{ // this broke down
test: /\.js?$/,
loader: 'ng-annotate!babel-loader',
query: {
presets: ['es2015']
}
}
為什么第二個加載器配置不起作用? 有任何想法嗎?
經過一番挖掘,我找到了解決方案:
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loaders: ['ng-annotate', 'babel?presets[]=es2015']
},
我相信這與webpack如何加載查詢/預設有關。 它不知道預設適用於哪個加載程序。
請參閱babel-loader options ,它顯示了如何將選項作為查詢字符串傳遞
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.