Open jakearchibald opened 4 years ago
I'm not sure how this could work. CSS modules need to be imported from JS in order to use the class mapping they generate. I don't think we could reliably replace class names in HTML, because there's no way to reference which module you're referring to. If you had multiple <link rel="stylesheet">
tags pointing to different CSS modules, there's no way to know if <div class="whatever">
refers to the whatever
class in the first or second CSS file.
How would you expect it should behave? Do any other tools you know of support this?
Yeah, that's fair. I guess you'd need a system where you namespace the CSS tag, and reference that somehow:
<!doctype html>
<link rel="stylesheet" href="styles.module.css" parcel-module-prefix="main">
<div class="main.whatever"></div>
But, if no one wants that, that's fine.
Happy for this to be closed if the weird error is gone, which seems to be the case.
🙋 feature request
It seems like this works if postcss-modules is installed, but that doesn't appear to be documented.
The above fails to build, with error
@parcel/packager-html: HTML bundles must only contain one asset
.For completeness, here's
styles.module.css
:🤔 Expected Behavior
When importing from CSS, it seems to be working as expected.
When importing in HTML, I'd expect the class name in
<div class="whatever"></div>
to be renamed to match the module CSS.🔦 Context
Using CSS modules as part of a project.
💻 Examples
See above.