Xeen
Xeen

Reputation: 7003

webpack 4 scss loader doesn't work - why?

My configuration is:

{
  test: '/\.(css|scss)$/',
  exclude: /node_modules/,
  use: [
    'style-loader', 'css-loader', 'sass-loader'
  ]
}

but I get the following error:

ERROR in ./src/components/button/button.scss 1:10
Module parse failed: Unexpected token (1:10)
You may need an appropriate loader to handle this file type.
> $font-size: 20px;

What am I doing wrong?

Upvotes: 2

Views: 81

Answers (1)

Kirk Larkin
Kirk Larkin

Reputation: 93333

It looks like you're attempting to use a regex for test, but you're actually using a string. Remove the 's around the regex pattern and it should work:

{
    test: /\.(css|scss)$/,
    ...
}

Upvotes: 1

Related Questions