-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Common import(-once) doesn't happen after reference-import #3040
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
Currently there are two possible workarounds, but both seem to be bad:
Actually, in our code it is used separately. Just like this: some-other-main.less @import 'foo';
@import 'qux';
main.less @import 'foo';
@import (multiple) 'bar'; But that doesn't seem to be a good practice due of several reasons:
|
I'm wondering if the issue should be generalized to all (applicable) import options, not just
|
@seven-phases-max Yes, I believe you're right. |
Just to clarify my use-case. In our projects there are several css builds (say, final css files) that may include different combinations of common less files (components). Some components use variables and mixins from other components, so if they go to some build that doesn't include them, LESS compilation will fail. So I'm trying to organize requirejs-like dependency structure, putting reference imports on top of the dependent component code. |
Mixins and variables should not require |
That is true if file doesn't contain anything but mixins and variables. One more case is |
This hack (used only to emulate non-existing "extending mixins" feature) is better to be hidden in a separate file, and no top-level Less component should still ever use |
So, generally you're saying "We have reference import, but don't use it. Put your globals to separate file instead" :) |
The reference import is invented as a kludge to re-use existing CSS libraries only, no Less library is supposed to ever have it inside in a normal situation (it's OK to have it for the |
A frightening thing you're saying! :-O And some time ago I also proposed a similar story to Stylus: stylus/stylus#2139 BTW, how a CSS library may be used with |
That is, if for example you have something like // "clearfix.less":
@import (reference) "clearfix-auxiliary-details.less"; // only in this file and nowhere else
.clearfix_() {
&:extend(.clearfix_ all);
} So anywhere else in you library you always import "clearfix.less". |
Well, not everybody will be agree with me (specifically in calling it "kludge"). There's a ticked where we were discussing this in details (1: "it's a hack, we should advertise to minimize or at least limit its use" -> 2: "yeah maybe it'a hack, but it's a cool hack" -> 1: "...." etc.) but I can't find it right now. Well, just take the count into account: "extend/reference" issues/bugs open by now (it's tens, not just a few). This is because when P.S. As for your example at tylus/stylus#2139, it's fine as long as we do not enter another "thing to avoid" when designing a library from scratch (as oppose to easy re-use of existing libraries): "never reuse existing CSS rulesets as mixins and/or with extend" (it's another big story though and I do not want to pollute the ticket even more...). |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
One more strange and unexpected import case.
Common import (without
multiple
, but with expected CSS output) doesn't happen if the same file was already reference-imported earlier.The fileset to reproduce:
main.less
bar.less
foo.less
Expected CSS output for
main.less
compiled:Actual CSS output for
main.less
compiled:The text was updated successfully, but these errors were encountered: