How do you consume a library's CSS? #1018
-
It seems like there's some general confusion around CSS with TSDX (evidenced by a discussion (#947) and three separate issues, #186, #959, and #1015). Reading @agilgur5's answer in #947, this line jumped out to me:
This feels spot on. Furthermore, if my But, notably, there's notably, there's no So, with that preamble, I'm wondering how are library consumers supposed to import the CSS that's being packaged? (I feel like an "inexperienced library consumer". |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So as I believe I've mentioned in some of those issues, this question is not TSDX-specific, particularly as TSDX is currently agnostic and has no opinion regarding your styling decisions -- by default, it does not even come with a CSS plugin for Rollup. So how you consume styles in a library is up to the library author. Some people use
To be more explicit than above, there is no single convention, and that's one of the reasons why TSDX is agnostic (can probably link to some issues stating this originating rationale too)
That's actually just a naming issue -- I noticed that in #627 when I added integration tests for the example and would like to change that default naming if possible. You're only including one CSS plugin with one config, so it only generates one file (unlike the JS which has multiple output formats). The example shows |
Beta Was this translation helpful? Give feedback.
So as I believe I've mentioned in some of those issues, this question is not TSDX-specific, particularly as TSDX is currently agnostic and has no opinion regarding your styling decisions -- by default, it does not even come with a CSS plugin for Rollup. So how you consume styles in a library is up to the library author.
Some people use
styled-components
, others inject a stylesheet, others require the consuming developer to import the CSS (or have a plain version with no styles), others let you pass props to style components or add your own styles. There are more methods too, some libraries let you pick themes or build your own theme and customize pieces of it. And there are many, many dif…