less.ruby icon indicating copy to clipboard operation
less.ruby copied to clipboard

Allow @imports without including the imported file in the output

Open obeattie opened this issue 16 years ago • 3 comments

I'm using LESS for a fairly large project, and I have to say that it's been fantastic so far. Saved me goodness knows how long and just makes things much less "painful" — in general, I have few complaints, and most of those that I do have are already covered. I think I have found something that (I think) would probably be fairly trivial for you to implement, and would make modularising my files far easier.

Currently, if I am to @import something at the top of one of my files, the (compiled) contents of that file will also be included in the output. For instance, if I have a forms.css file, and I want to import its contents into my overlay.css file (so that I could use the variables and mixins defined in forms.css), there's no way of doing this without having the contents of forms.css also output. Since I am compiling all these files myself (with our build system) and compressing them, this can quickly result in a great deal of duplicate output. To solve this, the only thing I've been able to do so far is to lump all of my CSS into one file (which is currently at about 3000 lines!).

So, if there were a way for me to import the namespace of another .less file into the current namespace, without it being included in the output, that would be fantastic. Please consider it =)

obeattie avatar Jan 09 '10 12:01 obeattie

what about putting all variables & mixins declarations into one separate file and @import it in all others?

jtousek avatar Jan 09 '10 16:01 jtousek

I actually just this last few minutes found out about dynamic mixins… so I guess that's fine. It'd be really useful if things like that were documented somewhere (actually, maybe they are, just in docs I don't know about!)

obeattie avatar Jan 09 '10 17:01 obeattie

I really would like this as well as it would be way easier to subclass stuff in for example twitter bootstrap (not just their mixins.less)

andriijas avatar Sep 24 '12 08:09 andriijas