Closed
Description
Trying to separate style into more manageable blocks, and hitting a rather unexpected "undefined variable" error. I have four files: color variables, component style, and two theme styles. Component imports theme styles, theme styles import color variables.
// colors.less
@black: #000000;
@red: #000000;
// button.less
button {
// …
@import "fooTheme";
@import "barTheme";
}
// fooTheme.less
&.theme-foo {
@import (reference) "colors";
color: @red;
}
// barTheme.less
&.theme-bar {
@import (reference) "colors";
color: @black;
}
When compiling all this I get an exception 'variable @black is undefined in file …/barTheme.less'
. Bar gets imported after foo, meaning the exact same imports work in foo, but when it gets to bar, it fails. If I leave only one theme import, it works as expected.
It almost seems like less checks if that file is already imported and ignores it, but when it gets to pulling variable values, they are not really in that scope, causing it to fail. Am I doing something silly or is there a bug?
Metadata
Metadata
Assignees
Labels
No labels