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

I am trying to incorporate the lessc compiler into a large project that has a basic setup from Bootstrap, and this only leads to different compilers (for which there are tickets for everyone with different solutions).

None of the solutions give me what I want, this is a way to compile a less loadable string.

I will compile various other assets via node.js and hope to do the same with a smaller one, but every google page I find on this issue is node.js + Express, which I don't want. I want a standalone compiler. (Idea: require.js r.js file)

I found Node-less , but he did not see the update after 2 years and as such is not perfect.

So. Question: Is there a command line method for compiling files with node.js? Perfect imp:

node compiler.js build.js

where build.js is the file with the empty bootstrap.less file and everything else.

Example r.js configuration file:

({
    baseURL : "../assets",
    mainConfigFile : "../assets/main.js",
    name : "../assets/main",
    out : "../assets/main.optmin.js",
    optimize : "uglify"
})
+5
source share
1 answer

Here's 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. It may be simple, but I did not find it ANYWHERE on the net. This line can be included in the deployment script.

+11
source

All Articles