less

LESS: Compiler that merges and minifies all imported files


I have a complex nested tree of .less files organized as a main.less file that imports several other secondary files with @import clause. In some cases, these files import other ones.

For the moment I am in development mode, and files are compiled at runtime by LESS.JS compiler, but in production environment I would like to compile once all files and maybe merge all files alltogether. How to obtain this?

My intention would be:

  1. When I'll be ready for production, pass main.less path to a compiler
  2. Compiler analyzes main.less and if it encounters an @import clause, follows the link and compiles also imported file.
  3. This should be iterated for all files
  4. Finally I would like to have only one big .css file that is the merging (and maybe minimized) of all single .less files.

I tried SimpLESS compiler but it does not generate what I'm asking....


Solution

  • I found "LESS.js - Windows" that it works perfectly, even if is not graphical but only shell based. It's practically immediate in compiling and does not return errors in my less code (unlike all other graphical tools that I tested with the same code, such as WinLess and SimpLess).

    It is very similar to "node.js based" compiling tool, but it does not require any other package to be installed. Just download it and use it stand-alone. The only drawback is that last update is since beginning of 2014, so it could be outdated respect last new features of language.