Global scss variable
See original GitHub issueBug report
Sass variables in global file aren’t visible in .module scss files.
To Reproduce
- clone - https://github.com/vitaliemiron/nextjs-global-scss
- npm i
- npm run dev
SassError: Undefined variable.
╷
3 │ color: $blue;
Screenshots
System information
- Version of Next.js: 9.3.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Variables - Sass
Variables declared at the top level of a stylesheet are global. This means that they can be accessed anywhere in their module after...
Read more >Sass Variables - W3Schools
!global indicates that a variable is global, which means that it is accessible on all levels. Look at the following example (same as...
Read more >css - SASS - use variables across multiple files - Stack Overflow
You can do it like this: I have a folder named utilities and inside that I have a file named _variables.scss.
Read more >!default and !global | Sass in the Real World: book 1 of 4
Currently, using variables in Sass where there is a value set in the global space and then one set within the context of...
Read more >Global SCSS Variables in Nuxt - Medium
Global SCSS Variables in Nuxt ... 3. In the assets folder, create a new directory called “scss.” Inside of this new directory, create...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Whats the point of creating variables in global file when they need to be imported in each stylesheet ?
I’ll recommend creating a common scss file includes all variables/functions/mixins, and also set up a webpack alias for that file. Then in the component sass files, you could
@use "common" as *;and start using all your variables.