尝试使用带有nodeJS的构建脚本构建LESS(更少的css) [英] Trying to build LESS (less css) using a build script with nodeJS

查看:163
本文介绍了尝试使用带有nodeJS的构建脚本构建LESS(更少的css)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用NodeJS来构建我们的项目。我们已经将LESS CSS集成为项目的一部分。我们试图保持我们的构建干净,并希望能够调用lessc命令(或类似的东西),以建立我们的LESS文件。

We are using NodeJS to build our project. We have integrated LESS CSS as a part of the project. We are attempting to keep our build clean and would like to be able to call the lessc command (or something comparable) in order to build our LESS files.

LESS文档不是很深入,而是想与社区联系,寻找解决方案。

The LESS documentation isn't very in depth, but wanted to reach out to the community to find a solution. Google has not be too helpful to me on this topic.

我们有一个build.sh文件,调用各个其他build.js文件(在相应的目录中)。如何运行LESSC编译我的LESS文件?

We have a build.sh file, that calls various other build.js files (in respective directories). How can I run LESSC to compile my LESS files?

推荐答案

使用node.js

var less = require('less')
    ,fs = require('fs');

fs.readFile('style.less',function(error,data){
    data = data.toString();
    less.render(data, function (e, css) {
        fs.writeFile('style.css', css, function(err){
            console.log('done');
        });
    });
});

这篇关于尝试使用带有nodeJS的构建脚本构建LESS(更少的css)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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