4 years ago

Compiling LESS on the fly

Posted 4 years ago by alexleonard

I'm building an application where multiple companies can be added to the system. Each company can, optionally, modify some of the colour elements on the site.

I was looking at this package: as perhaps being something that could be used to generate and cache the LESS on the fly but am not really sure how it would work - I'd need to get HEX colour codes from the database and into some LESS variables in a LESS file for dynamic generation.

Perhaps that's not an option. I thought it might be best to ping here to see if anyone's done this before and had any advice.

I'm assuming I'd need something whereby I have my default-variables.less file, and then say default-rules.less which imports all my standard rules. Then a default.less file which imports default-variables.less and default-rules.less.

For each company I'd need to have a company-name.less file which imports default-variables.less, overrules the specific colour variables, then imports default-rules.less. But I'm not really sure how to do this dynamically, with caching..!

Any suggestions?

Please sign in or create an account to participate in this conversation.