I have one file named style.scss with the following code:
@import 'variables';
body {
color: $text-color;
background: $background-color;
}
And one partial named _variables.scss:
$colorscheme: white;
@if $colorscheme == white {
$text-color: #333;
$background-color: #fff;
}
@else {
$text-color: #ccc;
$background-color: #333;
}
The if-statement works properly, but the variables defined inside, do not work. When I try to compile it, I keep getting:
Syntax error: Undefined variable: “$text-color”.
@if/@else
worked at that time. I played around a lot with that. Maybe it was a bug and it shouldn't have worked. :D Thanks for clarifying this anyway, @cimmanon.