-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested @import cause undefined variable or something like that #2672
Comments
By default, imports only import once. I haven't tested your code, but you probably will need to do something like:
That should work, according to docs. |
Thanks Matt, I've figured this out earlier in the day, but this behaviour is confusing at very least. Auto-applied I'm sure there's a reason / use case for such behaviour, could you explain to the stupid why and when this is useful in different contexts?
|
@ianbytchek Less used to import multiples by default, but a common complaint was that this sometimes caused unexpected behavior. (See #622.)
You are probably correct.
It's more the reverse. It wasn't designed that way because of a specific use case. It wasn't designed the way you're suggesting because there WASN'T a specific use case suggested in order to add "different behavior per context" or "different behavior for reference". Basically, imports simply evaluate once by default, and since you can specify when you want to evaluate more than once, it keeps the behavior consistent (albeit perhaps not useful in your case). There are many other ways of "importing" variables into that context as well, so I'm not sure another feature is needed. |
Thanks @matthew-dean, makes sense overall. |
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.
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?
The text was updated successfully, but these errors were encountered: