Hi,
I have trouble making the plugin work with Webpack 5 + SCSS. I had a working setup with the original gajus/babel-plugin-react-css-modules, Webpack 4, and SCSS. During the migration to Webpack 5 I had to swap the original plugin for yours (thank you for maintaining the fork!). The configuration remained mostly the same.
I have created a minimalistic example here: https://github.com/vlastimil-dolejs/css-modules-scss-bug
The error I get is:
ERROR in ./src/Test.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
CssSyntaxError: C:\code\css-modules-scss-bug\src\Test.scss:6:4: Expected a pseudo-class or pseudo-element.
at C:\code\css-modules-scss-bug\src\Test.scss:6:3
at Input.error (C:\code\css-modules-scss-bug\node_modules\postcss\lib\input.js:148:16)
at Rule.error (C:\code\css-modules-scss-bug\node_modules\postcss\lib\node.js:60:32)
at Root._error (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:177:25)
at Root.error (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\selectors\root.js:43:19)
at Parser.error (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:740:21)
at Parser.expected (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:1133:19)
at Parser.pseudo (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:875:19)
at Parser.parse (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:1084:14)
at Parser.loop (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:1043:12)
at new Parser (C:\code\css-modules-scss-bug\node_modules\postcss-selector-parser\dist\parser.js:164:10)
@ ./src/index.js 3:0-26 4:50-54
The error is thrown, when there is some special SASS construct in the .scss file. It looks like the class name lookup is done in .scss file before it is processed by postcss-scss.
Relevant part of babel.config.js
const plugins = [
["@dr.pogodin/react-css-modules", {
"exclude": "node_modules",
"generateScopedName": "[path][name]__[local]",
"filetypes": {
".scss": {
"syntax": "postcss-scss"
}
}
}]
];
Relevant part of webpack.config.js
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[path][name]__[local]",
},
importLoaders: 1, // to include sass-loader
sourceMap: true,
}
},
"sass-loader"
]
}
Hi,
I have trouble making the plugin work with Webpack 5 + SCSS. I had a working setup with the original gajus/babel-plugin-react-css-modules, Webpack 4, and SCSS. During the migration to Webpack 5 I had to swap the original plugin for yours (thank you for maintaining the fork!). The configuration remained mostly the same.
I have created a minimalistic example here: https://github.com/vlastimil-dolejs/css-modules-scss-bug
The error I get is:
The error is thrown, when there is some special SASS construct in the .scss file. It looks like the class name lookup is done in .scss file before it is processed by
postcss-scss.Relevant part of babel.config.js
Relevant part of webpack.config.js