有没有SASS.js?像LESS.js? [英] Is there a SASS.js? Something like LESS.js?

查看:203
本文介绍了有没有SASS.js?像LESS.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前使用过 LESS.js 。很容易使用,例如

I have used LESS.js before. It's easy to use, something like

<link rel="stylesheet/less" href="main.less" type="text/css">
<script src="less.js" type="text/javascript"></script>

我看到 SASS.js 。如何以类似的方式使用它?解析SASS文件以立即在HTML中使用。看起来SASS.js更适用于 Node.js

I saw SASS.js. How can I use it in a similar way? Parsing a SASS file for use immediately in HTML. It seems like SASS.js is more for use with Node.js?

var sass = require('sass')
sass.render('... string of sass ...')
// => '... string of css ...'

sass.collect('... string of sass ...')
// => { selectors: [...], variables: { ... }, mixins: { ... }}


推荐答案

没有正式批准的sass或scss的JavaScript实现。

There is no officially sanctioned JavaScript implementation of sass or scss. There are a couple of implementations in progress that I've seen, but none that I can recommend using at this time.

但是,请注意以下几点:

However, please a few points:


  1. 为什么要让所有的用户编译你的样式表,一次为所有用户做一遍。


  2. 如果您决定在未来更改为服务器端实施,则必须相应地更改所有模板。
  3. >
  1. Why should you make all your users compile your stylesheets when you can do it once for all of them.
  2. What would your site look like if JavaScript is disabled.
  3. If you decide to change to a server-side implementation at a future time, all your templates must be changed accordingly.

因此,虽然有一些更多的设置开始,我们(sass核心团队)认为服务器端编译是最好的长期方法。同样,较少的开发人员喜欢生产样式表的服务器端编译。

So while it's a little more setup to get started, we (the sass core team) think that server side compilation is the best long term approach. Similarly, the less developers prefer server side compilation for production stylesheets.

这篇关于有没有SASS.js?像LESS.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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