4 ms·
I've been using CSS Modules in a couple of projects (combined with PostCSS), am pretty happy so far. I think you could actually go one step further and embed t
by andrewingram 11y ago
I've been using CSS Modules in a couple of projects (combined with PostCSS), am pretty happy so far.
I think you could actually go one step further and embed the stylesheet in the React component's module using a tagged template string, I haven't looked into how you'd get webpack to extract this into CSS files, but I'm sure it's possible.
Eg: https://gist.github.com/AndrewIngram/e3af5e8b70fd89a9a0d3 https://gist.github.com/AndrewIngram/e3af5e8b70fd89a9a0d3
- xzyfer 11y agoI've thought about this also. Alternatively some mixed format file like yaml front matter style.
- andreypopp 11y agoThat (extraction) can be done (React Style does that) but for it to be consistent with JS semantics you need to evaluate code at build time because such template strings can contain interpolations from JS world.
- andrewingram 11y agoAh yes, forget about the interpolation issue. I knew there was a reason I stopped digging into it