5

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"
})
JMDE
  • 1,085
  • 11
  • 14

1 Answers1

11

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.

JMDE
  • 1,085
  • 11
  • 14
  • Depending on how you've set things up, you probably don't need to be calling lessc via node. For example, on my system, I installed less via npm, and lessc is a standalone executable. – aaronsnoswell Aug 19 '12 at 17:38