我正在尝试在项目中使用DotLess,但我遇到了一个似乎无法解决的问题。我试图通过在我自己的自定义文件中使用LESS mixin来扩展预先存在的CSS文件(实际上来自JQuery UI)。
在jquery-ui-1.8.20.custom.css中:
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; }
我的custom.less文件的相关部分:
@import "./jquery-ui-1.8.20.custom.css";
.sortable-list li:hover {
.ui-state-hover;
}
当我尝试使用以下DotLess命令编译它时:
.\dotless-compiler -m [LESS_FILE_PATH]\custom.less .\custom.generated.css
我收到以下错误消息:
.ui-state-hover is undefined on line 92...
[91]: .sortable-list li:hover {
[92]: .ui-state-hover;
----^
[93]: }[Done]
a)有没有人知道我是否缺少命令行编译器的参数? (文档,它真的很棒......)
b)如果没有,LESS有一些固有的缺点,无法处理我所描述的情况吗?扩展您无法触摸的现有CSS文件似乎是一个非常常见的用例。
答案 0 :(得分:1)
将导入的文件扩展名更改为.less - 否则它会假定它实际上是css并逐字导入文本,而不会进行任何处理。
如果你运行没有参数的无点编译器,它会显示所有允许的参数。一个是 -a - import-all-less - 将每个导入视为较少,即使以.css结尾
所以你可以尝试而不是重命名文件。
然后你可能会发现有些东西需要被转义,但是手指越过它会起作用。