Luca Detomi
Luca Detomi

Reputation: 5716

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

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?

Upvotes: 0

Views: 366

Answers (1)

SLaks
SLaks

Reputation: 887413

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.

Upvotes: 1

Related Questions