【问题标题】:Difference between module.loaders and module.rules in webpack.config.jswebpack.config.js 中 module.loaders 和 module.rules 的区别
【发布时间】:2018-04-04 10:17:43
【问题描述】:

我希望在 Babel 中使用 typescript 加载器,我看到了:

https://github.com/TypeStrong/ts-loader

module.exports = {
  module: {
    rules: [
      { 
        test: /\.tsx?$/, 
        use: [
          {
            loader: 'ts-loader', 
            options: {
              transpileOnly: true
            }
          }
        ]
      }
    ]
  }
}

为什么使用module.rules 而不是module.loaders?例如,我本来希望看到这个:

module.exports = {
  module: {
    loaders: [    // loaders instead of rules
      { 
        test: /\.tsx?$/, 
        use: [
          {
            loader: 'ts-loader', 
            options: {
              transpileOnly: true
            }
          }
        ]
      }
    ]
  }
}

有什么区别?

【问题讨论】:

标签: typescript webpack webpack.config.js


【解决方案1】:

规则是在 webpack 2 中引入的。你看到的加载器是 webpack 1 的一部分。

【讨论】:

    猜你喜欢
    • 2022-01-08
    • 2020-10-24
    • 2017-06-04
    • 1970-01-01
    • 2011-10-12
    • 2011-02-17
    • 2016-10-18
    • 2012-07-03
    • 2013-10-25
    相关资源
    最近更新 更多