Closed VadimZvf closed 2 years ago
With css-loader@3.6.0 all works fine
I use generateScopedName: '[local]--[hash:base64:5]',
in server babel config
and localIdentName: '[local]--[hash:base64:5]',
in client (webpack) config
It turns out, in some cases classNames really don't match. But you can generate them by yourself. someFIle.js
const crypto = require('crypto');
const generateScopedName = (localName, resourcePath) => {
const getHash = value => crypto.createHash('sha256').update(value).digest('hex');
const hash = getHash(`${resourcePath}${localName}`).slice(0, 5);
return `${localName}__${hash}`;
};
server babel config
[
'css-modules-transform',
{
generateScopedName,
devMode: true,
},
],
client webpack config
{
loader: 'css-loader',
options: {
modules: {
getLocalIdent: ({ resourcePath }, _, localName) => generateScopedName(localName, resourcePath),
},
},
},
classNames
don't match for me either, I'm using css-loader@5.0.1
and babel-plugin-css-modules-transform@1.6.2
classNames dont match with css-loader@2.0.0 or above with css-loader@1.0.1 all fine