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?
You can set the map to exist as null be default, which means that if it isn't explicitly set anywhere, then the variable still exists but with a null value. You can then check if the value of the variable is null using an if statement.