Compass with Ruby-SassCompiler not found

I have a little ruby โ€‹โ€‹script that uses Compass to compile * .scss files, since Compass and Sass are based on ruby. I just use 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') 

This 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 using:

 Compass.sass_compiler.compile('css/index.scss', 'test.css') 

Which causes an error saying that the SassCompiler (NoMethodError) class is not defined.

I really would like to use the proposed method, but can I use it and what do I need in the future?

Thanks for the help!

+2
ruby compass-sass
source share
1 answer

After digging to its original state, I finally found it!

 require 'compass/sass_compiler' 

- missing line!

The last line to start compilation is as follows:

 Compass.sass_compiler.compile! 

Here it is.

Btw: the Compass.sass_compiler method accepts some parameters ( source ) that are passed to the compiler, but using Compass.add_configuration as above performs the same Job.

I hope someone can use this information, happy compilation!

EDIT

Due to comments here is the complete code that works for my project. It is included in the assembly script, the following lines follow from initialization:

 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 lines run in every compilation:

 compiler = Compass.sass_compiler({ :only_sass_files => [ '<path to scss file to compile>' ]}) compiler.compile! 

To get an overview of all the possible options, I recommend looking at the source and official documentation of sass and compass.

+4
source share

All Articles