LESS: generate different CSSs for different theme (color variation)

爷,独闯天下 提交于 2019-12-02 14:19:48

问题


I would like to manage creation of different "theme" for my site, using LESS.

My idea is to generate different compiled .css files, using each time a specific variable.less that is imported by root file.

Here a simple example:

1) I have 2 different color scheme in 2 distinct files: variable1.less and variable2.less.

2) A file style.less should have an @import rule like "@import variableX.less" and obviously this 'X' should change assuming values '1' and '2'.

3) Compiler should then generate style1.css and style2.css, each based on relative variable1.less and variable2.less.

How to obtain this?


回答1:


You need to flip your import directions.

The style.less file should not import any variables.

Instead, each variableN.less file should import style.less after defining all of its variables.
These files will then each compile to a full set of rules based on their variable values.



来源:https://stackoverflow.com/questions/28370158/less-generate-different-csss-for-different-theme-color-variation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!