【问题标题】:configuration error: has an unknown property 'loaders'配置错误:有一个未知的属性 'loaders'
【发布时间】:2018-09-29 09:04:24
【问题描述】:

我正在根据木偶指南使用 webpack 和 NPM 安装木偶。 我修改 webpack.config.js 如下:

var webpack = require('webpack');

module.exports = {
entry: './app/driver.js',
module: {
loaders: [
  {
    test: /\.html$/,
    loader: 'underscore-template-loader'
  }
 ]
 },
 output: {
 path: __dirname + '/static/js',
 filename: 'bundle.js'
 },
 plugins: [
 new webpack.ProvidePlugin({
   _: 'underscore'
 })
 ],
resolve: {
 modules: [__dirname + '/node_modules', __dirname + '/app']
 },
 resolveLoader: {
 modules: [__dirname + '/node_modules']
 }
};

但是在构建应用程序时,我遇到了错误: 配置对象无效。 Webpack 已使用与 API 模式不匹配的配置对象进行初始化。 - configuration.module 有一个未知的属性 'loaders'。这些属性是有效的: object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, WrappedContextCritical?, WrappedContextRecursive?, WrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? } -> 影响正常模块的选项 (NormalModuleFactory)。

您能帮忙解决这个错误吗?

【问题讨论】:

    标签: webpack


    【解决方案1】:

    .loaders 已弃用:查看 webpack 文档 here

    此选项已弃用,取而代之的是 Rule.use。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-28
      • 2018-08-18
      • 2018-03-12
      • 2017-04-16
      • 2021-10-29
      • 2017-07-17
      • 1970-01-01
      • 2012-09-08
      相关资源
      最近更新 更多