sveltestrap icon indicating copy to clipboard operation
sveltestrap copied to clipboard

Global style causes unused CSS to be downloaded

Open vostrnad opened this issue 1 year ago • 0 comments

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.

vostrnad avatar Mar 06 '23 00:03 vostrnad