Ошибка webpack configuration.module имеет неизвестное свойство 'loaders' - PullRequest
3 голосов
/ 27 января 2020

Когда я запускаю сервер, используя npm run start, я получаю следующую ошибку:

✖ 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration has an unknown property 'debug'. These properties are valid:

   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }

   The 'debug' property was removed in webpack 2.0.0.

   Loaders should be updated to allow passing this option via loader options in module.rules.

   Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:
   plugins: [
     new webpack.LoaderOptionsPlugin({
       debug: true
     })
   ]
 - configuration.module has an unknown property 'loaders'. These properties are valid:

   object { defaultRules?, exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, strictExportPresence?, strictThisContextOnImports?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? }

   -> Options affecting the normal modules (`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
    })
  ]
};

Ответы [ 2 ]

3 голосов
/ 27 января 2020

Какая у вас версия веб-пакета?

Что касается веб-пакета 4 - вам нужно перейти с "загрузчиков" на "правила"

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

Надеюсь, что это так ответ, который вы ожидаете.

0 голосов
/ 27 января 2020

Вы должны изменить загрузчики на правила в веб-пакете 4:

изменить loaders

на rules. См. Загрузчики

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

module.exports = {
  entry: [
    './src/Main.js'
  ],
  output: { path: __dirname, filename: 'bundle.js' },     
  devtool: 'source-map',
  module: {
   rules: [
  { test: /\.glsl$/, use: 'webpack-glsl' }
]
  },
  devServer: {
    compress: true,
    disableHostCheck: true,
  },
  plugins: [
    new webpack.LoaderOptionsPlugin({
      debug: true
    })
  ]
};

чтобы увидеть свойство отладки. См. Отладка

...