How to compile less css?

In previous post, we came to know that Less is a css pre-processor that allow variables, functions, mixins to make it more extendable and maintainable.

Less CSS file named with .less extension but to run .less should be converted to .css file extension. There are various ways to convert style.less to style .css . The easiest way on command line, to install Less on the server, is via npm, the node.js package manager-

compile less css

Instructions to install node js package manager –

1 – First you need to install node js pacakage, Go to http://nodejs.org/ and download node js and install.

How to install node js pacakage on windows ?

Install the Less module-

2 –  Run npm install less -g

3- Run lessc style.less > style.css (it will compile style.less to style.css)

There are several ways to convert .less files to css but i suggest a command-line compiler, lessc.

Note – Every time, you do changes in style.less then please run lessc style.less > style.css command to update changes in style.css.

There are many other ways also to convert Less CSS to regular css (We convert LESS CSS to regular css because  browsers understands regular css).  Some free apps like SimpleLESS , WinLESS , LESS.app . But you  need to install all these apps to use.

Some online tools also available for LESS to CSS conversions like  –

1-  http://www.webtoolkitonline.com/less-to-css.html

2 – http://less2css.org/

There are lots of tool available, Choose the best one alternative and work.  Please share in comments what everyone using to convert LESS CSS.

8 Comments

Leave a Reply