Skip to content
Discussion options

You must be logged in to vote

This is almost always a Sass module issue, not a webpack one. With @use, variables are scoped to the file that loads them. sass-loader's additionalData only prepends code to the root stylesheet webpack hands to Sass (your entry _global/_main.scss). Nested files that Sass pulls in via @use "typography.scss" never see that prepended @use, so $global__line-height is undefined inside typography.scss.

That matches what you already found: putting @use "…/_abstract/_main.scss" as *; inside typography.scss works.

1. Preferred: load abstracts in each partial that needs them

// src/_global/typography.scss
@use "../_abstract/main" as *;

body {
  line-height: $global__line-height;
}

Do the same in l…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Nazrinn
Comment options

Answer selected by Nazrinn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants