QSem
@QSem
о себе?!

Pug and WebPack, не работает?

Здравствуйте. Проблема в следующем...
Есть мой веб пак конфиг, вот код:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/joker/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, '../dist/joker')
  },
  resolve: {
      alias: {
          '@': '../src',
          '@joker': '../src/joker/js'
      }
  },
  loaders: [
    {
      test: /\.pug$/,
      include: path.join(__dirname, '../src/joker/pug/'),
      loaders: [ 'pug-loader' ]
    }
  ],
  plugins: [
    new HtmlWebpackPlugin({
      template : './index.pug',
      inject   : true
    }),
    new HtmlWebpackPlugin()
  ]
};


Структура такая:
../src/joker/pug/ - путь в котором лежит pug file
Все пакеты поставил.....
При запуске (npm run start) дает ошибку:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'loaders'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.
   For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: [
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           loaders: …
         }
       })
     ]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack-demo@1.0.0 start: `npx webpack --config ./configs/webpack.config.js --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-demo@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Администратор\AppData\Roaming\npm-cache\_logs\2019-04-04T09_54_25_026Z-debug.log


Не могу понять в чем проблема, спасите, пАмАгите)
Честно, перегуглил много, не смог понять принцып сборки и почему падает мой код
  • Вопрос задан
  • 1352 просмотра
Пригласить эксперта
Ответы на вопрос 1
@artemonuchin
Блин,
loaders:
серьёзно?

Должно быть

module: {
    rules: [
        {
            test: /\.pug$/,
            include: path.join(__dirname, '../src/joker/pug/'),
            loaders: [ 'pug-loader' ]
        }
     ],
}


Это не говоря уже о том, что банально надо было перевести, если с английским трудно, текст ошибки.
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'loaders'.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы