开发者

Importing LESS CSS Files with variables

I have 2 LESS CSS files called core.less and style.less

core.less is located under: \css\core.less and its contents are below:

body {
    background: @bg_color;
    color: @font_color;
}

style.less is located under: \css\green\style.less and its contents are below:

@bg_color: #0F0;
@font_color: #FFF;
@import "../../core.less";

The core.less file contains all the css rules, in LESS format, but does not provide the definitions for the variables.

The style.less defines all the variables referenced in core.less, and then imports the core.less file.

I have no problems compiling style.less as it imports all the rules from the core file. The core.less file cannot be compiled - it will generate errors since it does not contain the variable definitions.

I would now like to compile the core.css file as well (just to make sure there are no errors in my LESS rules). Is there any way of adding some kind of dummy/placeholder variables in the core.le开发者_高级运维ss file such that it can also be complied without generating errors and still work with the setup I have explained above?

I am open to suggestions on changing the format / structure of the files.


By importing core.less into style.less you are compiling the "LESS rules" of core.less.


Perhaps you should not define variables, needed in core.less, outside of core.less. I typically make "core" files (in any programming language, really) have no dependencies on the rest of the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜