CSS 没有红宝石的 Sass 或 Compass ?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12657008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sass or Compass without ruby?
提问by Troy Cosentino
Is there a way to use Sass or Compass or anything like that without Ruby?
有没有办法在没有 Ruby 的情况下使用 Sass 或 Compass 或类似的东西?
I have been looking around google and this site and can't find anything, any help would be appreciated. Thank you
我一直在浏览谷歌和这个网站,找不到任何东西,任何帮助将不胜感激。谢谢
采纳答案by tftd
Sass was originally written for Ruby, but now they've created libSasswhich is a C/C++
port of the Sass engine, which makes it easier to integrate the engine into an IDE or another language. At this point, you can use the Sass engine in Ruby, Node.js, Python, PHP, Java, .NETand others. For more information, visit libSass. Also, your IDE might have a plugin which would support Sass, without the need of ruby by using the libSass.
Sass 最初是为 Ruby 编写的,但现在他们创建了libSass,它是C/C++
Sass 引擎的一个端口,可以更轻松地将引擎集成到 IDE 或其他语言中。此时,您可以在 Ruby、Node.js、Python、PHP、Java、.NET等中使用 Sass 引擎。有关更多信息,请访问libSass。此外,您的 IDE 可能有一个支持 Sass 的插件,而无需使用 libSass 的 ruby。
The original answer below may or may not apply to your situation (depends on whether or not your language has implemented support for libSass or not). I decided to leave it the way it is for archive reasons.
下面的原始答案可能适用也可能不适用于您的情况(取决于您的语言是否已实现对 libSass 的支持)。出于存档原因,我决定保持原样。
Sass (requires Ruby)
Sass(需要 Ruby)
Sass is written in Ruby, so you'll need Ruby installed as well. Taken from sass's site
Sass 是用 Ruby 编写的,因此您还需要安装 Ruby。 取自 sass 的网站
Compass (requires Ruby, as it's based on SASS)
Compass(需要 Ruby,因为它基于 SASS)
Compass is an open-source CSS authoring framework which uses the Sass stylesheet language to make writing stylesheets powerful and easy. Taken from compass's site
Compass 是一个开源的 CSS 创作框架,它使用 Sass 样式表语言使编写样式表变得强大而简单。 取自指南针的网站
Less (written in js, requires node.js or less.js included in the page)
Less(js编写,需要页面中包含node.js或less.js)
LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. LESS runs on both the client-side (Chrome, Safari, Firefox) and server-side, with Node.js and Rhino. Taken from Less's site
LESS 使用动态行为(例如变量、mixin、操作和函数)扩展 CSS。LESS 运行在客户端(Chrome、Safari、Firefox)和服务器端,使用 Node.js 和 Rhino。取自Less的网站
These are the main processors out there that I know of. You may write your own parser/port for any another language of choice.
这些是我所知道的主要处理器。您可以为任何其他选择的语言编写自己的解析器/端口。
In other words, no you can't use sass/compass without having Ruby because the program itself (sass & compass) IS written in Ruby. So you'll definitely need it in order to run it.
换句话说,没有 Ruby 就不能使用 sass/compass,因为程序本身(sass 和 compass)是用 Ruby 编写的。所以你肯定需要它来运行它。
回答by Alejandro García Iglesias
It's true that the question is not clear enough, but i'll try to address some issues. There areother CSS pre-processors that don't rely on Ruby (two coming to my mind right now are Less, which i've used and liked, but not as powerful as Sass, and Stylus, which i haven't used, both based on JavaScript), but as you're specifically asking about Sass+Compass, and as i'm still looking for the same answer, i'll talk about that.
这个问题确实不够清楚,但我会尝试解决一些问题。还有是不依赖于红宝石(二来我的脑海其他CSS预处理器现在是少,我已经使用并喜欢,但不是那样强大无礼的话,和手写笔,我没有用过,两者都基于 JavaScript),但是当您专门询问 Sass+Compass 并且我仍在寻找相同的答案时,我将讨论这个问题。
@JamundFerguson said:
@JamundFerguson 说:
Is there a way to compile Sass without Ruby? Depends.
有没有办法在没有 Ruby 的情况下编译 Sass?要看。
There is
有
Sass is a pre-processing language. There's a compiler built in Ruby for it and anyone can write a compiler in any language. There's a C implementation of a Sass compiler called libsasswhich can be used on any language that allows to import C libs. It's the library used by node-sass, which is a compiler built in Node.js, which I didn't tried yet and don't know how it could work and if it's ready for production use. It may be a question of time for Compass to be ported (maybe you end up doing that?) and so we can have a compiler which doesn't depends on the Ruby gem (currently, there's a node-compassmodule that doesrelies on the Ruby gem).
Sass 是一种预处理语言。Ruby 为它内置了一个编译器,任何人都可以用任何语言编写编译器。有一个名为libsass的 Sass 编译器的 C 实现,它可以用于任何允许导入 C 库的语言。它是node-sass使用的库,它是一个内置于Node.js的编译器,我还没有尝试过,不知道它是如何工作的,以及它是否可以用于生产。Compass 被移植可能是一个时间问题(也许你最终会这样做?)所以我们可以有一个不依赖于 Ruby gem 的编译器(目前,有一个node-compass模块确实依赖于红宝石宝石)。
Other languages
其他语言
So far i've mentioned the possibility for a Node.js compiler, which, as you may know, it's a JavaScript environment, being the language of the web and my language of choice. But you didn't specified which language you would like the compiler to be written into. I think there may be compilers built in many languages, for example, @EricMeyer mentioned a Pythoncompiler. Maybe he's using pyScss? That seems to have built-in support for Compass. But then you need a Python environment. So the thing is: you'll need someenvironment for a compilerunless you run natively compiled binaries. (Less has less.js which can be included on the page to run client-side and avoid the compiling step, but it's not meant for using it on production.)
到目前为止,我已经提到了 Node.js 编译器的可能性,正如您所知,它是一个 JavaScript 环境,是网络语言和我选择的语言。但是您没有指定您希望将编译器写入哪种语言。我认为可能有多种语言构建的编译器,例如,@EricMeyer 提到了一个Python编译器。也许他正在使用pyScss?这似乎内置了对指南针的支持。但是你需要一个 Python 环境。所以问题是:除非您运行本机编译的二进制文件,否则您将需要一些编译器环境。(Less 有 less.js,它可以包含在页面上以运行客户端并避免编译步骤,但它并不意味着在生产中使用它。)
Native apps
原生应用
I've worked for a year with CodeKit, which does very well, compiles Sass/Compass, Less, Stylus and template languages like Haml, Slim, Jade, etc. Rebuilds your assets when they change automatically and you see the changed on your browser immediately. The only thing that i didn't liked was that when moving to a different computer, installing CodeKit, checking out project and trying to use it, i had to reconfigure the project settings, which i had to remember so i could get to a build like the one i made in the other computer. Also i started working with a team, and they had also to configure the project with the same settings (sometimes not having the same project config lead to ugly inconsistencies) and also members of the team using Ubuntu couldn't use it. That's why i started to think on making a command-line tool to build projects and discovered Gruntimmediately, and fell in love with it. As @Dave mentioned, there's Scoutand also there's LiveReload, but haven't used them.
我在CodeKit工作了一年,它做得非常好,编译 Sass/Compass、Less、Stylus 和模板语言,如 Haml、Slim、Jade 等。当它们自动更改时重建您的资产,您会立即在浏览器上看到更改。我唯一不喜欢的是,当移动到另一台计算机、安装 CodeKit、检查项目并尝试使用它时,我必须重新配置项目设置,我必须记住这些设置,以便我可以进行构建就像我在另一台电脑上做的那样。我也开始与一个团队合作,他们还必须使用相同的设置来配置项目(有时没有相同的项目配置会导致丑陋的不一致),并且使用 Ubuntu 的团队成员也无法使用它。那'立即,并爱上了它。正如@Dave 提到的,有Scout和LiveReload,但没有使用它们。
Conclusion
结论
Conclusion is i have not a strong conclusion. I'm still looking for the same answer, but i hope this answer sheds a little bit of light on the status of compiling Sass/Compass outside of the Ruby environment.
结论是我没有一个强有力的结论。我仍在寻找相同的答案,但我希望这个答案对在 Ruby 环境之外编译 Sass/Compass 的状态有所了解。
回答by gkond
Actually there is a library that provides binding for Node.js to libsass, the C version of the Sass: https://npmjs.org/package/node-sass
实际上有一个库可以将 Node.js 绑定到 libsass,即 Sass 的 C 版本:https://npmjs.org/package/node-sass
It allows you to natively compile .scss files to css at incredible speed without Ruby installed.
它允许您在不安装 Ruby 的情况下以惊人的速度将 .scss 文件本地编译为 css。
To install just run:
要安装只需运行:
npm install node-sass
And there is also a Grunt extension if needed: https://github.com/sindresorhus/grunt-sass(this is what I've been looking for in this question)
如果需要,还有一个 Grunt 扩展:https: //github.com/sindresorhus/grunt-sass(这是我在这个问题中一直在寻找的)
Find out more at: https://github.com/andrew/node-sass
了解更多信息:https: //github.com/andrew/node-sass
回答by Dave
Just a little bit of an update on this, you can use SCSS/SASS files and generate the correct files on the fly without installing Ruby by using a program called Scout.
只需对此进行一点更新,您就可以使用 SCSS/SASS 文件并通过使用名为 Scout 的程序即时生成正确的文件,而无需安装 Ruby。
Scout has its own self contained ruby environment and is coded in java so make sure you java is up to date before using. Linky here.
Scout 有自己独立的 ruby 环境,并且是用 java 编码的,所以在使用之前请确保您的 java 是最新的。链接在这里。
Regards :)
问候 :)
回答by Dean Peterson
You can actually parse sass without ruby, you can use node-sass. details here: https://github.com/andrew/node-sass
您实际上可以在没有 ruby 的情况下解析 sass,您可以使用 node-sass。详情请见:https: //github.com/andrew/node-sass
回答by Amir Abiri
If this is for .NET, there is now a wrapper for libsass. Available from Nuget.
如果这是用于 .NET,现在有一个用于 libsass 的包装器。可从Nuget 获得。
回答by Bangash
Adobe Brackets(free, open source) can compile LESS, SASS and Stylus when the files are changed, and update styles during live preview, you just need to install required extensions from the extension manager. Get Bracketsand enjoy !
Adobe Brackets(免费,开源)可以在文件更改时编译 LESS、SASS 和 Stylus,并在实时预览期间更新样式,您只需要从扩展管理器安装所需的扩展。获取括号并享受!
Edit: As other questions suggest node-sassis also a good option if you have nodejs already installed.
编辑:如果您已经安装了 nodejs,其他问题表明node-sass也是一个不错的选择。