在项目中使用Node.js作为独立的LESS编译器? [英] Use Node.js as standalone LESS-compiler in project?

查看:135
本文介绍了在项目中使用Node.js作为独立的LESS编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将 lessc 编译器合并到一个大型项目中,该项目具有从Bootstrap的基本设置,它只导致各种compileerrors(为其中有票的每个人都有不同的解决方案)。

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.

我通过node.js编译了各种其他资源,希望能用更少的东西做同样的事情,但每一个googlepage我发现的主题是Node.js + Express,这不是我想要的。我想要一个独立的编译器。 (Idea:require.js r.js-file)

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)

我找到节点 - 但没有看到在2年的更新,因此不是理想的。

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

所以。问题:有一个命令行方式来编译较少的文件与node.js?理想隐藏:

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

node compiler.js build.js

其中build.js是一个包含bootstrap.less路径和其他所有需要的文件。

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

.js配置文件:

({
    baseURL : "../assets",
    mainConfigFile : "../assets/main.js",
    name : "../assets/main",
    out : "../assets/main.optmin.js",
    optimize : "uglify"
})


推荐答案

是如何使用node和less输出到一个文件:

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

-x : compress

-O2:优化模式

它从main.less创建output.css。可能很简单,但我没有发现这在网上的任何东西。该行可以合并到部署脚本中。

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.

这篇关于在项目中使用Node.js作为独立的LESS编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆