Hacker News new | ask | show | jobs
by andrewingram 3958 days 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

2 comments

That (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.
Ah yes, forget about the interpolation issue. I knew there was a reason I stopped digging into it
I've thought about this also. Alternatively some mixed format file like yaml front matter style.