question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Global scss variable

See original GitHub issue

Bug report

Sass variables in global file aren’t visible in .module scss files.

To Reproduce

  1. clone - https://github.com/vitaliemiron/nextjs-global-scss
  2. npm i
  3. npm run dev
SassError: Undefined variable.
  ╷
3 │   color: $blue;

Screenshots

Screen Shot 2020-03-26 at 18 15 59

System information

  • Version of Next.js: 9.3.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:17
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
findshreycommented, Dec 11, 2020

Whats the point of creating variables in global file when they need to be imported in each stylesheet ?

4reactions
P233commented, Mar 27, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found