Skip to content

Invalid configuration object. #5452

@ghost

Description

Description

I followed the tutorial and the configurations, and it was working until my webpack.config.js was like this:

`const autoprefixer = require('autoprefixer');
const path = require('path');

function tryResolve_(url, sourceFilename) {
// Put require.resolve in a try/catch to avoid node-sass failing with cryptic libsass errors
// when the importer throws
try {
return require.resolve(url, {paths: [path.dirname(sourceFilename)]});
} catch (e) {
return '';
}
}

function tryResolveScss(url, sourceFilename) {
// Support omission of .scss and leading _
const normalizedUrl = url.endsWith('.scss') ? url : ${url}.scss;
return tryResolve_(normalizedUrl, sourceFilename) ||
tryResolve_(path.join(path.dirname(normalizedUrl), _${path.basename(normalizedUrl)}),
sourceFilename);
}

function materialImporter(url, prev) {
if (url.startsWith('@Material')) {
const resolved = tryResolveScss(url, prev);
return {file: resolved || url};
}
return {file: url};
}

module.exports = {
entry: ['./app.scss', './app.js'],
output: {
filename: 'bundle.js',
},
module: {
rules: [
{
test: /.scss$/,
use: [
{
loader: 'file-loader',
options: {
name: 'bundle.css',
},
},
{loader: 'extract-loader'},
{loader: 'css-loader'},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
autoprefixer()
]
}
}
},
{
loader: 'sass-loader',
options: {
// Prefer Dart Sass
implementation: require('sass'),

 // See https://github.com/webpack-contrib/sass-loader/issues/804
 webpackImporter: false,
 sassOptions: {
   importer: materialImporter,
   includePaths: ['./node_modules'],
 },
        },
      }
    ],
  },
  {
    test: /\.js$/,
    loader: 'babel-loader',
    query: {
      presets: ['@babel/preset-env'],
    },
  }
],

},
};`
The error in my console is :

**[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.module.rules[1] has an unknown property 'query'. These properties are valid:
    object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
    -> A rule description with conditions and effects for modules.**

Browser/OS Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions