bestguy / sveltestrap

Bootstrap 4 & 5 components for Svelte
https://sveltestrap.js.org
MIT License
1.3k stars 183 forks source link

Global style causes unused CSS to be downloaded #535

Open vostrnad opened 1 year ago

vostrnad commented 1 year ago

SvelteKit downloads an extra CSS file /_app/immutable/assets/Offcanvas.60614438.css when Sveltestrap is used. The entire contents of the file is as follows: (64 bytes including a newline)

.modal-open,.overflow-noscroll{overflow:hidden;padding-right:0}

Digging through the code, this seems to be caused by global styles in Modal and Offcanvas:

// Modal.svelte
<style>
  :global(.modal-open) {
    overflow: hidden;
    padding-right: 0;
  }
</style>

// Offcanvas.svelte
<style>
  :global(.overflow-noscroll) {
    overflow: hidden;
    padding-right: 0px;
  }
</style>

I don't use either of these components in my code but the CSS is still downloaded. I'm not sure whether the components need to be rewritten or it can be fixed some other way.