Let's say we have an npm package with React components. These components have/need styling. Some styles are overridable, for example, colors or dim...
For further actions, you may consider blocking this person and/or reporting abuse
It depends on SSR. Without SSR it it could be a simple
inject-style-tagsolution, like react-style-singleton.With SSR it become complex.
.cssSo - I would say - CSS. CSS with a
webpack-loaderof you choice, ornode-loaderto do the same, like css-modules-require-hook. It's just keeps a bit more freedom for everyone.react-style-singleton is interesting I need to play with it. I didn't quite get the idea behind css-modules-require-hook, what the value there
css-modules-require-hookis just a good example of anode-loader. Like - you may process source CSS and transform to the thing you need, like you may do usingwebpack-loader.Almost nobody consider this as an option, or calling some loader-based approaches bad, cos they are not repeatable for node, while they are :)
What about babel-plugin-transform-postcss? I think this is better than css-modules-require-hook, because postcss and postcss-modules are used directly. And no CSS is actually included in the resulting JavaScript
A very good option
I was recently stumbled upon this situation and finally uploaded the CSS file from package itself.
I also generate one asset manifest file which has location of main css file.
Now, it's upto consumer app to use it as
<Link>tag or add it in their bundle.Some responses from twitter: