问题描述
我有一个小小的ruby脚本,它使用Compass来编译* .scss文件,因为Compass和Sass是基于ruby的,我只是像这样直接使用编译器(基于):
要求'compass'
需要'sass'
Compass.add_configuration({
:project_path =>'。',
:sass_path =>' css',
:css_path =>'css',
:output_style =>:compressed
},'custom')
Compass.compiler.compile ('css / index.scss','css / index.css')
可以正常工作并进行编译,但是,我也收到以下消息:
Compass.compiler已过时。请改用Compass.sass_compiler。
所以我尝试使用:
Compass.sass_compiler.compile('css / index.scss','test.css')
引发错误的原因,表明未定义类 SassCompiler
(NoMethodError)。
我真的很想使用建议的方法,但是我可以使用它,以及我必须提前做什么?
感谢您的帮助!
在深入研究源代码之后,我终于找到了它!
需要'compass / sass_compiler'
是缺少的行! / p>
运行编译的最后一行如下:
Compass .sass_compiler.compile!
就是这样。
Btw .: Compass.sass_compiler
方法接受一些选项()移交给编译器,但如上所述使用 Compass.add_configuration
可以做到这一点求职。
我希望有人可以使用此信息,编译愉快!
编辑 >
由于此处的注释适用于我的项目的完整代码。它包含在构建脚本中,以下几行来自初始化:
require'compass'
require'罗盘/ sass_compiler'
Compass.add_configuration({
:project_path => _(),
:output_style =>:expanded,
:cache_path => ;'<缓存路径>',
:http_fonts_path =>'../fonts',
:fonts_dir =>'<字体的相对路径>',
: sass_path =>'< scss文件的路径>',
:css_path =>'<编译后的css>',
:http_images_path =>'../img' ,
:images_path =>'<图像的路径>'
},'自定义名称')
这些行在每次编译中运行:
compiler = Compass.sass_compiler({
:only_sass_files => [
'<要编译的scss文件的路径>'
]})
editor.compile!
要获得所有可能选项的概述,我建议您查看以下来源和官方文档ass和指南针。
I have a little ruby script that uses Compass to compile *.scss files, since Compass and Sass are ruby-based I am just using the compiler directly like this (based on this SO question):
require 'compass'
require 'sass'
Compass.add_configuration({
:project_path => '.',
:sass_path => 'css',
:css_path => 'css',
:output_style => :compressed
},'custom')
Compass.compiler.compile('css/index.scss', 'css/index.css')
That works as expected and does the compilation, BUT, I also get this message:
Compass.compiler is deprecated. Use Compass.sass_compiler instead.
So I tried to use:
Compass.sass_compiler.compile('css/index.scss', 'test.css')
What throws an Error, telling that the class SassCompiler
(NoMethodError) is not defined.
I really would like to use the suggested method, but can I use it and what do I have to require in ahead?
Thanks for help!
After digging a bit into the source, I finally found it!
require 'compass/sass_compiler'
is the missing line!
The final line to run the compilation looks like that:
Compass.sass_compiler.compile!
Thats it.
Btw.: the Compass.sass_compiler
method accepts some options (source) which are handed over to the compiler, but using Compass.add_configuration
as above does the same Job.
I hope somebody can use this Information, happy compiling!
EDIT
Due to the comments here the complete code that works for my project. It is included in a build script, the following lines are from the initialisation:
require 'compass'
require 'compass/sass_compiler'
Compass.add_configuration({
:project_path => _(),
:output_style => :expanded,
:cache_path => '<path to cache>',
:http_fonts_path => '../fonts',
:fonts_dir => '<relative path to fonts>',
:sass_path => '<path to the scss files>',
:css_path => '<path fot the compiled css>',
:http_images_path => '../img',
:images_path => '<path to images>'
},'custom-name')
And these line run in each compilation:
compiler = Compass.sass_compiler({
:only_sass_files => [
'<path to scss file to compile>'
]})
compiler.compile!
To get an overview of all possible options I recommend a look at the source and at the official documentation of sass and compass.
这篇关于Ruby中的指南针—找不到SassCompiler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!