[英]Confusion surrounding @import behaviour in LESS, using Codekit
Currently using Bootstrap, compiling with Codekit, and also have a separate style.less that I'm working on. 目前正在使用Bootstrap,使用Codekit进行编译,并且还有一个单独的style.less,我正在努力。
In variables.less: 在variables.less:
@blue: #0096EF;
In style.less, I have the following: 在style.less,我有以下内容:
.title-text {color: @blue;}
@import: "variables.less";
In bootstrap.less: 在bootstrap.less:
@import: "style.less";
@import: "variables.less";
Am I doing this right? 我这样做了吗? To my mind, when bootstrap is compiled it results in variables.less occurring twice.
在我看来,当编译bootstrap时,它会导致变量无效。
you should be able to go with import of variables.less once in bootstrap as first import instance, and do not include it second time in actual style.less. 你应该能够在bootstrap中作为第一个导入实例导入变量。并且不要在实际样式中第二次包含它。 Because you are right on your assumption, it will import variable.less again.
因为你的假设是正确的,它将再次导入variable.less。 meaning you are importing same variables in two locations.
意味着您在两个位置导入相同的变量。
PS as long as variables.less that defines variables that you will be using is imported before you access variables themselves you will be fine. PS只要variable.less定义你将使用的变量是在你自己访问变量之前导入的,你会没事的。
@color-black: #000;
.color {
color: @color-black;
}
I discovered this is also a Codekit issue too, as I am using Codekit to compile the less files. 我发现这也是一个Codekit问题,因为我使用Codekit编译较少的文件。
Solution: 解:
@import
style.less @import
style.less Incidentally, I encountered a Codekit bug between step 2 and 3. After step 2, Codekit no longer watches or compiles anything. 顺便说一句,我在第2步和第3步之间遇到了Codekit错误。在第2步之后,Codekit不再监视或编译任何内容。 To solve, I needed to remove the watched project and then re-add it to Codekit.
要解决这个问题,我需要删除已监视的项目,然后将其重新添加到Codekit中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.