Skip to content

Re-exporting components grabs all styles #164

Answered by Anidetrix
warlo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @hanswilw, @kelvinlouis,

CSS is automatically included even if only the parts of the file it's in are used since it's considered a necessary side effect because rollup cannot understand if it's needed or not by itself.

Although there are some ways to limit the used CSS:

I also saw there is a possibility to use treeshakeable in the injector options:

That's one way to do it, but it is limited to inject mode.

Another way is to use include/exclude options, e.g.:

If you had a component named indicator inside components directory and you wanted to exclude all its styles do:

styles({
  exclude: ["**/components/indicator/**"]
});

...or, on the opposite, if you wanted to include only its styles:

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Anidetrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #147 on January 28, 2021 08:07.