-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Cannot put import by reference inside of a mixin #2162
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
Comments
I think I may have rushed the logic on this a bit, as I'm now realizing that the order of me calling the mixin and importing the file does make sense the way it is, as I am calling the mixin after the original import call. That's what I get for staring at it for too long. I think the focus of this issue should be shifted to the fact that I can't put the (reference) import inside of the mixin without losing the reference functionality. I'm going to edit the text a bit to reflect this. |
Alright, I've adjusted the issue to take out the parts related to my original misconceptions. Your note about the mixin being able to be called before it is defined is actually a really useful point, which could solve my problem completely, regardless of the issue that's now highlighted in this case, but I still think this issue could be a potential problem in some other use-cases. Sorry for the confusion! |
This should be fixed by #2729 . |
I have been working on a complex importing strategy where I set all of my paths in a config file, and then use a mixin to import various different components as needed.
This approach doesn't seem to work well with files imported by reference, however. It seems that importing a file by reference inside of a mixin in this way causes it to output all of the contents of the file, and not just what is used.
To give you a very simplified example, I have something like this:
So,
certain-file.less
contains a rule settingh1
to be black, but I want to override that in my main less file.. using a class name that was specifically made to be extended (imported by reference so that the original class name of._color-white
is not output into my code)But that messes with the (reference) import, giving me this final output:
Which technically works, but means I've got extra unwanted selectors being dropped into my code.. which is especially bad when in reality, my
last-file.less
is a big file full of "extension" classes, many of which don't even get used on every project.I believe the problem lies in the fact that importing by reference inside of a mixin causes all styles inside that file to be output, rather than just when they are used.
The text was updated successfully, but these errors were encountered: