【问题标题】:webpack config for js with ng-annotate-loader & babel-loader带有 ng-annotate-loader 和 babel-loader 的 js 的 webpack 配置
【发布时间】:2016-09-23 21:37:02
【问题描述】:

我尝试了 2 种方法来同时为我的 *.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']
    }
}

为什么第二个加载器配置不起作用?有什么想法吗?

【问题讨论】:

    标签: javascript angularjs webpack


    【解决方案1】:

    经过一番挖掘,我发现这是解决方案:

    {
      test: /\.js$/,
      exclude: /(node_modules|bower_components)/,
      loaders: ['ng-annotate', 'babel?presets[]=es2015']
    },
    

    我相信这与 webpack 如何加载查询/预设有关。它不知道预设适用于哪个加载器。

    参见babel-loader options,它展示了如何将选项作为查询字符串传递

    【讨论】:

      猜你喜欢
      • 2016-07-28
      • 2015-12-03
      • 1970-01-01
      • 2019-02-24
      • 2018-01-14
      • 2018-07-06
      • 2016-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多