Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Node.js as standalone LESS-compiler in project?

I've been trying to incorporate the lessc compiler in a large project that has the basic setup from Bootstrap and it only results in various compileerrors (for which there are tickets for everyone with different solutions).

Not one solution give me what I want, which is a way to compile the less-pile through the command line.

I compile various other assets through node.js and hoped to do the same thing with the less, but every googlepage I find on the subject is Node.js+Express which is not what I want. I want a standalone compiler. (Idea: require.js r.js-file)

I found Node-less but it hasnt seen a update in 2 years and as such isnt ideal.

So. Question: Is there a commandline way to compile less-files with node.js? Ideal impl:

node compiler.js build.js

where build.js is a file with path to bootstrap.less and everything else needed.

Example of a r.js config file:

({
    baseURL : "../assets",
    mainConfigFile : "../assets/main.js",
    name : "../assets/main",
    out : "../assets/main.optmin.js",
    optimize : "uglify"
})
like image 871
JMDE Avatar asked Jun 09 '12 12:06

JMDE


Video Answer


1 Answers

Here is how to use node and less to output to a file:

node path/to/less/bin/lessc -x -O2 path/to/assets/main.less > path/to/output.css

-x : compress

-O2 : optimization mode

which creates output.css from main.less. Might be simple but I havn't found this ANYWHERE on the net. That line can be incorporated in a deployment-script.

like image 120
JMDE Avatar answered Sep 27 '22 18:09

JMDE