-
-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temporary fix for those have trouble with newer version of webpack / css-loader. #304
Comments
But still, the best way to solve this is an update of this package. LOL 😂 |
I just gave this a try and the hash in the JSX still failed to match the hash in the generated CSS. I tried with latest |
Sorry to hear that. Have you checkout the name-generator of css in your builder like webpack to see if its using the newest |
I've found out an approach that is more decent with {
"resolutions": {
"generic-names": "^3.0.0"
},
} This force all packages in node_modules to use |
I am not using For now I am just sticking with |
@wallzero I had to also specify context for createGenerator('[local]-[hash:base64:5]', { context: 'src/client' }),
// ^
// |
// |
// |
// Without { context } it didn't work correctly So now my babel.config.js looks +/- like below const createGenerator = require('generic-names');
// ... later in the code where plugins are defined
[
'react-css-modules',
{
context: 'src/client',
filetypes: {
'.scss': {
syntax: 'postcss-scss',
plugins: [
[
'postcss-nested',
{
bubble: ['@include'],
preserveEmpty: true,
},
],
],
},
},
generateScopedName: createGenerator('[local]-[hash:base64:5]', { context: 'src/client' }),
webpackHotModuleReloading: env === 'development',
exclude: 'node_modules',
handleMissingStyleName: 'throw',
},
] Hopefully it will help somebody. |
@hinok Thanks! I hadn't mentioned I had used the context parameter and I still couldn't get it to work. Although maybe it will help someone else. Like I said, I am using a shared configuration between projects and requiring downstream projects to resolve For now I am using the fork |
It turns out that
babel-plugin-react-css-modules
is usinggeneric-names
v2, which is different a bit with newerWebpack
in the [hash].generic-names
v3 solve it. see this update.So we can manually replace the
generateScopedName
withcreateGenerator
fromgeneric-names
v3.Like this
I've done this in my own project and it works fine. Have a try. Best wishes~
The text was updated successfully, but these errors were encountered: