我正在使用 wro4j 1.7.3 和 less4j/lessCSS 编译器。
preProcessors=less4j,
yuiCssMin,googleClosureSimple
在我的 wro.xml 中,我有类似的东西:
<group name='css'>
<css>/resources/css/base.css</css>
</group>
编译时,我会得到一个错误,因为 wro4j 将我的 *.css 文件也视为 *.less 文件。
Exception occured while processing: ro.isdc.wro.WroRuntimeException:
Could not compile less. 1 error(s) occured:
ERROR 437:1 missing EOF at '}' in stylesheet (which started at 23:1)
, class: ro.isdc.wro.WroRuntimeException,caused by:
com.github.sommeri.less4j.Less4jException Could not compile less. 1 error(s) occured:
ERROR 437:1 missing EOF at '}' in stylesheet (which started at 23:1)
当使用 lessCSS 而不是 less4j 时,错误原因会更好地显示:
MEZ: [ERROR] Exception occured while processing: ro.isdc.wro.WroRuntimeException: Could
not execute the script because:
{
"type": "Runtime",
"message": "error evaluating function `saturate`: Cannot find function toHSL in object
[object Object].",
"filename": null,
"index": 11114.0,
"line": 754.0,
"callLine": null,
"callExtract": null,
"stack": null,
"column": 17.0,
"extract": [
".img-saturate{ ",
" -webkit-filter: saturate(500%);",
" -moz-filter: saturate(500%);"
]
}, class: ro.isdc.wro.WroRuntimeException,caused by: Could not execute the script
because:
{
"type": "Runtime",
"message": "error evaluating function `saturate`: Cannot find function toHSL in
object [object Object].",
"filename": null,
"index": 11114.0,
"line": 754.0,
"callLine": null,
"callExtract": null,
"stack": null,
"column": 17.0,
"extract": [
".img-saturate{ ",
" -webkit-filter: saturate(500%);",
" -moz-filter: saturate(500%);"
]
}
更改处理器顺序没有帮助:
preProcessors=yuiCssMin,googleClosureSimple
postProcessors=less4j
错误仍然存在。
有没有可能,比如 wro4j,它不应该将以 css 结尾的文件视为 less。
最佳答案
谢谢亚历克斯,
通过使用 less4j.less,less-processor 将只扫描 less-files:
preProcessors=less4j, yuiCssMin,googleClosureSimple
#postProcessors=less4j
然而,后来我找到了错误的真正原因。 css 文件中缺少结束大括号。通过添加大括号,一切正常!
关于wro4j less-compiler 也编译 .css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21953836/