You need to reference the file where that mixin is, by doing @import
.
/* mixin.less */
.title(){
text-decoration: none
}
/* reset.less */
@import "mixin.less";
.title {
.title();
}
One way to organize your files is to create a structure similar to this:
- less
|- build
| |- mixin.less
| - variables.less
| - functions.less
... outros *.less
So you can keep the files separate, keeping each .less a specific function. The only file from which the CSS will be generated is the one in the build directory. An example, of separating using the above structure:
/* variables.less */
@background-color: #fff;
@font-color: #333;
This file is not aware of any .less .
functions.less
has access to the variables file to use in the functions, for example:
@import "variables.less";
.transform(@arguments){
-webkit-transform: @arguments;
-ms-transform: @arguments;
transform: @arguments;
}
.paint-div(){
color: @font-color;
background: @background-color
}
And finally the build file. This can ignore the variable file access only to the functions file:
@import "../functions.less"; /* subindo um nível pois ele está dentro do diretório 'build'*/
.main {
.paint-div();
}
.main {
& a {
.transform(translateX(200px) rotate(6deg));
}
}
When compiled, the stylesheet:
.main {
color: #333333;
background: #ffffff;
}
.main a {
-webkit-transform: translateX(200px) rotate(6deg);
-ms-transform: translateX(200px) rotate(6deg);
transform: translateX(200px) rotate(6deg);
}