webpack错误配置。模块具有未知属性'loaders'

问题描述 投票:0回答:1

[当我使用npm run start运行服务器时,出现以下错误

✖wds」:无效的配置对象。已使用与API架构不匹配的配置对象初始化Webpack。

  • 配置具有未知的属性'debug'。这些属性有效:

    对象{amd?,bail?,cache?,context?,dependencies?,devServer?,devtool?,entry?,externals?,infrastructureLogging?,loader?,mode?,module?,name?,node?,optimization ,输出,并行性,性能,插件,配置文件,recordsInputPath,recordsOutputPath,recordsPath,resolve,resolveLoader,服务,统计,目标,watch,watchOptions。 }

    'debug'属性在webpack 2.0.0中已删除。

    应该更新加载程序,以允许通过module.rules中的加载程序选项传递此选项。

    直到加载程序被更新,您可以使用LoaderOptionsPlugin将加载程序切换到调试模式:插件:[新的webpack.LoaderOptionsPlugin({调试:true})]

  • configuration.module具有未知的属性'loaders'。这些属性有效:

    对象{defaultRules?,exprContextCritical?,exprContextRecursive?,exprContextRegExp?,exprContextRequest?,noParse ?、规则?,strictExportPresence?,strictThisContextOnImports?,unknownContextCritical?,unknownContextRecursive?,unknownContextRegExp?,unknownContextRequest?,UnsafeCache?,wappedWeddedC ?,wrappedContextRegExp? }

    ->影响普通模块(NormalModuleFactory)的选项。

我的webpack.config.js如下:

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: [
    './src/Main.js'
  ],
  output: { path: __dirname, filename: 'bundle.js' },
  cache: true,
  debug: true,
  devtool: 'source-map',
  module: {
    loaders: [
      {
        test: /\.glsl$/,
        loader: 'webpack-glsl',
        include: [
          path.resolve(__dirname, 'src', 'shaders')
        ]
      }
    ]
  },
  devServer: {
    compress: true,
    disableHostCheck: true,
  },
  plugins: [
    new webpack.LoaderOptionsPlugin({
      debug: true
    })
  ]
};
javascript npm webpack xdebug loader
1个回答
0
投票

您的webpack版本是什么?

对于webpack 4-您需要从“加载程序”更改为“规则”

module: {
    rules: [
      { test: /\.glsl$/, use: 'webpack-glsl' }
    ]
  ...

希望这是您期望的答案。

© www.soinside.com 2019 - 2024. All rights reserved.