Reputation: 1516
This article on the Svelte website says, "The compiler (in Svelte's case) can identify and remove unused styles. No more append-only stylesheets!"
There are two options for loading Bootstrap SCSS:
@import 'node_modules/bootstrap/scss/bootstrap';
Would Svelte's compiler eliminate the need to do #2 above? It would be pretty cool if I don't have to get into the details of what in Bootstrap I am and am not using and still get the smallest possible generated CSS.
Upvotes: 1
Views: 420
Reputation: 5482
Svelte's unused style removal happens at the component level. It analyzes the selectors used in your component's <style>
tag and removes anything not present in your component's markup. Because of this, if you wanted it to remove unused Bootstrap selectors, you would need to import the Bootstrap SCSS into every component so that the compiler could analyze which selectors are being used in that component. Due to Bootstrap's size, this is not recommended. It will massively slow down your build time, since the compiler has to analyze all of Bootstrap's styles for every component. Also, you would end up with duplicated Bootstrap styles across components.
Because of that, I recommend adding Bootstrap to your global SCSS and following Bootstrap's documentation on removing unused styles.
Upvotes: 3