You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be great to be allow style scoping for components, layouts and pages using <style src="file.scss">, to an external stylesheet like svelte-preprocess or even how Nuxt allows it with <style scoped src="./file.scss" lang="scss"> with the scoped and/or src options.
Background & Motivation
As components and layouts can become quite large, I personally use and see a pattern of having an external stylesheet to separate the template and the logic from the styles like so:
src/components/organisms/Features/Features.astro
src/components/organisms/Features/Features.scss
Since SASS 1.8, using @import is now deprecated. Therefore, we need to either import a stylesheet using
---import'./Component.scss'---
but then, we lose the scoping in component/page/layout which is not ideal.
Or, with the recommended @use/@forward method, which requires to reimport the required variables/mixins/functions/etc in each stylesheet, defeating the purpose of the Vite config additionalData option:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Body
Summary
(Originally started in an issue I created)
It'd be great to be allow style scoping for components, layouts and pages using
<style src="file.scss">
, to an external stylesheet likesvelte-preprocess
or even how Nuxt allows it with<style scoped src="./file.scss" lang="scss">
with thescoped
and/orsrc
options.Background & Motivation
As components and layouts can become quite large, I personally use and see a pattern of having an external stylesheet to separate the template and the logic from the styles like so:
src/components/organisms/Features/Features.astro
src/components/organisms/Features/Features.scss
Since SASS 1.8, using @import is now deprecated. Therefore, we need to either import a stylesheet using
but then, we lose the scoping in component/page/layout which is not ideal.
Or, with the recommended
@use
/@forward
method, which requires to reimport the required variables/mixins/functions/etc in each stylesheet, defeating the purpose of the Vite configadditionalData
option:Goals
additionalData
from the Vite config to "inject" the required stuff into each fileBeta Was this translation helpful? Give feedback.
All reactions