简体   繁体   中英

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?

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)$/,
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM