#how to import scss in a component

3 messages · Page 1 of 1 (latest)

opal olive
#

I cant access anything from the imported scss . What am I missing?

example:

<style lang="scss">
  @use "variables.scss";
  
  div{
    background: $somecolor; // Undefined variable
  }
</style>
quiet quest
#

I could be wrong, I haven't use Sass recently but:

  • ˋ@use "variables.scss" means the namespace will be ˋvariablesˋ, so ˋvariables.$somecolorˋshould work
  • with ˋ@use "variables.scss" as varsˋ (or any custom namespace), you can access them with ˋvars.$somecolorˋ
  • to use ˋ$somecolorˋdirectly, I guess you could try ˋ@use "variables.scss" as *ˋ
opal olive
#

yes that worked! thank you so much 🙌