How do I check if a SASS Map already exists and only define one if this is not the case?
I have tried:
@if ($myMap) {
// do something
}
and
@if variable-exists($myMap) {
// do something
}
But I get the error Undefined variable: "$myMap"?
I'm sure this is pretty straightforward, but I can't seem to find the answer online?
It's a little confusing, but when checking for a variable's existence, skip the
$. You also need to set it as a global variable so it doesn't get scoped only to the@ifblock. This works: