Closed
Description
Consider this CSS modules setup with extract text plugin-
Section.css
.section__heading {
/* styles */
}
Section.js
import styles from './section.css'
function Section() {
return <section> <h1 className={ styles.section__heading }> H1 </h1> </section>
}
Current behavior
Currently, css-loader
goes through the normal process of creating a module out of the import, and even storing the original name mapping. The resulting JS file looks similar to
build.js (current)
// Module
"5mvV":
(function(module, exports) {
module.exports={
"section__heading":"_3a24I",
};
}),
// Usage
className={ __webpack_require__("5mvV").default.section__heading }
// ...
Expected behaviour
Ideally, css loader should just inline the "hashed" classname wherever its being used.
One of the benefits of hashing classnames is reduction in file sizes in comparison with techniques such as BEM. But if the original mapping is stored, this purpose is defeated.
build.js (expected)
// The classname is inlined
className="_3a24I"
Metadata
Metadata
Assignees
Labels
No labels