zoukankan      html  css  js  c++  java
  • Node环境下实现less编译

    今天在学习less的时候发现了在node中是可以渲染的,通过调用less的render方法渲染来生成css,所以写了个小Demo。

    var less = require('less');
    var http = require('http');
    http.createServer(function(req,res,err){	
        res.writeHead(200, {'Content-Type': 'text/plain charset=utf-8'});
        less.render(tmp,{compress: true}, function (e, css) {
            name = css['css'];
        });
        res.end(name);
    }).listen(8080);
    
    var name = null;
    var tmp = '
    @base: #f938ab;
    .box-shadow(@style, @c)when(iscolor(@c)){
    -webkit-box-shadow: @style @c;
    box-shadow: @style @c;
    }
    .box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
    .box-shadow(@style, rgba(0, 0, 0, @alpha));
    }
    .box {
    color: saturate(@base, 5%);
    border-color: lighten(@base, 30%);
    div { .box-shadow(0 0 5px, 30%) }
    }';
    

      

  • 相关阅读:
    Basic GC Tuning
    程序员如何少走弯路,更好的提升技术。
    WPF 多线程
    IOC
    一句话概括WPF知识点
    WPF数据绑定 Binding
    WPF命令
    WPF依赖属性
    WPF路由事件
    WPF绘图和动画
  • 原文地址:https://www.cnblogs.com/rainheader/p/4584048.html
Copyright © 2011-2022 走看看