I expected the same thing. I have a file called helpers.less and
I want to use variables and mixins from this helper in my other
.less files. I dont want the mixin rules from this file to
appear as separate css declarations in every file I @import it
all the 3 module require the font definition in default.fonts.less.
and I want to only do @import to the font definition at default.less, and when default.less then @import module less file, it should find the definition imported previously.
however, currently less version doesn't work this way.
and I need to do @import in every .less file that need any font definition.
and the final .css file generated contains a lot of duplications.
it will be good if the less author can consider this in the vnext.
I'm using the PHP implementation of LESS. I discovered the $ prefix for mixins simply by digging through its source code, so it might be an extra (undocumented) feature that was only implemented in the PHP version.
It's an excellent feature, though, pretty much critical to LESS, so I think it should be part of core LESS.
The workaround I've come to use is to define your mixin helpers as functions instead of classes. The notation to call the function is the same as mixing in a class, only the function does not get included in the css file. If you're having the issue of the js parser blowing up because the file is empty, include a /**/ comment in the file so it has something to output. There is a fork of the code that fixes that empty file concat error, but it hasn't yet been pulled into the master branch.
Sorry Adam, I didn't see your reply, Ben has the right syntax.
However, I have begun noticing duplicate css rules being inserted
when using this system. Unfortunately it seems this project has
been abandoned. I might be switching to the new SASS which has
LESS-like syntax, but is being actively developed.
yes nicholas i see what you mean. i have one file to process all
my other files (all.less - which imports all my other less files).
Because this contains multiple references to my mixins I now get
each mixin repeated for every import, which makes the file size