Skip to content

import statements options issue #3359

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

Closed
mohamedafzal03 opened this issue Jan 31, 2019 · 9 comments
Closed

import statements options issue #3359

mohamedafzal03 opened this issue Jan 31, 2019 · 9 comments
Labels

Comments

@mohamedafzal03
Copy link

//index.less
@import (multiple) "foo.less";
@import (multiple) "foo.less";

//foo.less
@import (once) "themes/haha/variable.less";
@import (once) "themes/haha/variable.less";

//themes/haha/variable.less
.className{
color:red;
}

css created by less compiler : (the "once" import option did not make sense here)
.className{
color:red;
}
.className{
color:red;
}
.className{
color:red;
}
.className{
color:red;
}

@mohamedafzal03 mohamedafzal03 changed the title importing statements options issue import statements options issue Jan 31, 2019
@matthew-dean
Copy link
Member

Are you saying you're getting imports duplicated?

Note that using the same filename twice in one file doesn't make sense, so I feel like there's something contrived about this example that doesn't map to what's really being used. Is there a repo or online project that demonstrates how this is actually being used?

@mohamedafzal03
Copy link
Author

As You mentioned "Note that using the same filename twice in one file doesn't make sense", it make sense in some cases beacause i can define some variables in one file and i can import it under any classes ,so check it up the example
https://github.com/mohamedafzal03/less_import_issues

@matthew-dean
Copy link
Member

@mohamedafzal03 🤔 There's no reason to do that because the variables you import in the top level will be accessible within that class. I suspect you may have some misconceptions either about how vars and/or how imports work?

@mohamedafzal03
Copy link
Author

mohamedafzal03 commented Feb 12, 2019

what if i want to import variables in only some classes which is not imported in top level?
Actually the point is if i import a file in multiple option like @import (multiple) "new.less"
if i imported another file inside new.less as @import (once) "newone.less" twice , the once option does'nt work (it is importing newone.less as twice without considering once option).
i.e Once option in import statement inside nested imported files did'nt works
once option inside multiple option file didn't works
@matthew-dean

@matthew-dean
Copy link
Member

what if i want to import variables in only some classes which is not imported in top level?

You can do this.

& {
  @import "themes/haha/variable.less";
  .class {
    // etc
  }
}

@mohamedafzal03
Copy link
Author

dude @matthew-dean
kindly consider this example

test.less

@import (multiple) "h1.less"; @import (multiple) "h1.less";

h1.less

@import (once) "h2.less"; @import (once)"h2.less";

h2.less ( example )

class{ color:red; }

as per docs

**once

The default behavior of @import statements. It means the file is imported only once and subsequent import statements for that file will be ignored.
Released v1.4.0
This is the default behavior of @import statements.
Example:

@import (once) "foo.less";
@import (once) "foo.less"; // this statement will be ignored

**
I am using same "once"option twice inside a importing file with option "multiple" it doesnt make any sense.(ie)once option doesn't make any sense in this case.
you can say there is no need to use like this
@import (once) "h2.less"; @import (once)"h2.less";
but as per docs
@import (once) "foo.less"; @import (once) "foo.less"; **// this statement will be ignored**
which is not ignored in this case

@seven-phases-max
Copy link
Member

I'm not quite sure I can follow the discussion - but I suspect this is basically one of faulty cases I mentioned in #3374 (comment)
Also (just in case)
@mohamedafzal03, when you say:

"once" import option did not make sense here

Do you actually mean:

"once" import option does not have any effect (or it is not applied) here

?

@mohamedafzal03
Copy link
Author

@seven-phases-max
Yes , as you said

"once" import option does not have any effect (or it is not applied) here

i.e when once is not effective only in the cases where the once option is written on the file which is imported in another file with multiple option .check it out !

@stale
Copy link

stale bot commented Dec 4, 2019

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.

@stale stale bot added the stale label Dec 4, 2019
@stale stale bot closed this as completed Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants