[Docs] Need guide for css-modules
See original GitHub issueThe problem
When you enable cssModules: true
options in your config css-loader
You get the next result:
body.no-webp__2343 .CollectriumSection_root__022e {
background: url(/_next/static/images/bg_collectrium-246049879ed73fd9d55f106344d77c0b.jpg) 100% / cover fixed no-repeat;
}
body.webp__2d34 .CollectriumSection_root__022e {
background: url(/_next/static/images/bg_collectrium-820955af9a57e6011b9180e00965b883.webp) 100% / cover fixed no-repeat;
}
To fix that I passed custom getLocalIdent
function:
const getLocalIdent = require('css-loader/lib/getLocalIdent');
const cssLoaderOptions = {
localIdentName: isProd ? '[hash:5]' : '[folder]_[local]__[hash:4]',
getLocalIdent: (
loaderContext,
localIdentName,
localName,
options,
) => {
if (localName.includes('webp')) {
return localName;
}
return getLocalIdent(
loaderContext,
localIdentName,
localName,
options,
);
},
}
Would be great to create a section Know Issues and add this case there
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Documentation about css-modules
A CSS Module is a CSS file in which all class names and animation names are scoped locally by default. All URLs (...
Read more >What are CSS Modules and why do we need them?
According to the repo, CSS modules are: CSS files in which all class names and animation names are scoped locally by default. So...
Read more >Component-Scoped Styles with CSS Modules
CSS Modules let you write styles in CSS files but consume them as JavaScript objects for additional processing and safety. CSS Modules are...
Read more >CSS modules
Why do we need CSS modules? · reuse styles · define a higher level semantic language we can rely on to promote consistency...
Read more >CSS modules
CSS modules do not have an official specification nor are they a browser feature. They are part of a compilation process that executes ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK, let’s add option to PostCSS plugin
Release 0.2 version.