withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
503 stars 59 forks source link

'class' scopedStyleStrategy breaks styles loaded into a custom cascade layer #855

Open chrisvaillancourt opened 1 year ago

chrisvaillancourt commented 1 year ago

What version of astro are you using?

2.5.7

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Firefox

Describe the Bug

Setting scopedStyleStrategy: 'class' in astro.config.mjs breaks component styles that load styles in a cascade layer.

This issue only occurs during a production build. Reverting to the default 'where' scope strategy resolves the style issue.

Example button when running npm run dev

image

Example button when running npm run build && npm run preview

image

To Reproduce

  1. Open the example reproduction
  2. run npm run dev and preview the output button
  3. stop the dev server and run npm run build && npm run preview and notice the difference in button styles

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vgh3h3?file=src%2Fcomponents%2FBtn.astro

Participation

natemoo-re commented 1 year ago

Sorry for the delay! This seems like a compiler issue because we're not properly handling :where styles. I'm going to move it over to that repo.