[英]How to avoid Duplication of CSS Classes while compile LESS to CSS
I am using less files for developing css but when I am compiling as css base.less get compile multiple times for eg: 我使用较少的文件来开发css但是当我编译为css base.less时,我会多次编译,例如:
style.less
@import 'base.less'
@import 'variable.less'
@import '../../dashboard/my-dashboard.less'
my-dashboard.less
@import 'base.less'
.my-dashboard-css{
all css goes here
}
when compiling style.less to style.css want to skip base.less from "my-dashboard.less" but i want to import base.less for reference for developer .Pls suggest me how to avoid me. 在编译style.less to style.css时想要从“my-dashboard.less”跳过base.less但是我想导入base.less以供开发人员参考.Pls建议我如何避免使用我。 Also Ihv tried @import(once) but its not working. Ihv也试过@import(曾经),但它不起作用。
You can import only references using keyword reference
: @import (reference) "foo.less";
您只能使用关键字reference
导入reference
: @import (reference) "foo.less";
. 。
http://lesscss.org/features/#import-options http://lesscss.org/features/#import-options
I agree to @3rdthemagical answer. 我同意@ 3rdthemagical的回答。 So for your answer follow the link as your guideline. 因此,对于您的回答,请按照链接作为指南。
Here's probably your output in the end. 这可能是你的输出到底。
style.less
@import (reference) 'base.less'
@import (reference) 'variable.less'
@import (less) '../../dashboard/my-dashboard.less'
my-dashboard.less
@import (reference) 'base.less'
.my-dashboard-css{
all css goes here
}
and here's my actual LESS CSS 这是我真正的LESS CSS
// CodeKit Framework Libraries [Bootstrap]
@import (reference) "utilities";
@import (reference) "variables";
@import (reference) "mixins";
// Internal Libraries
@import (less) "_fonts";
@import (less) "_mixins";
@import (less) "components/default";
@import (less) "components/menu";
@import (less) "components/header";
@import (less) "components/footer";
@import (less) "components/core";
Note: All under reference
will be my variables and mixins. 注意:所有被reference
都是我的变量和mixins。 And if you declare your import as less
it will read and import the file as less content. 如果您将导入声明为less
,则会读取并将文件导入为较少的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.