U
U
Uncle Vanya2019-04-04 13:58:48
Pug
Uncle Vanya, 2019-04-04 13:58:48

Pug and WebPack not working?

Hello. The problem is this...
I have my webpack config, here is the code:

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()
  ]
};

The structure is as follows:
../src/joker/pug/ - the path in which the pug file lies
All the packages installed .....
When running (npm run start) it gives an error:
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! [email protected]1.0.0 start: `npx webpack --config ./configs/webpack.config.js --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected]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

I can’t understand what the problem is, save me, please)
Honestly, I googled a lot, I couldn’t understand the assembly principle and why my code is falling

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
artemonuchin, 2020-02-21
@artemonuchin

Crap,

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

This is not to mention the fact that it was trite to translate, if it is difficult with English, the text of the error.
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'loaders'.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question