How to run sass in ruby?

How can I call the sass function from a ruby ​​file?

The following line works on the command line:

sass C:\Users\..etc..\main.scss 

I need to put this in a Ruby file. Therefore, I wrote, as shown below, in the Ruby file:

 require 'sass' $arg1 = 'C:/Users/dmoores/Desktop/testst/main.scss' sass $arg1 

But he complains about the following:

 undefined method `sass' for main:Object (NoMethodError) 
+6
source share
2 answers

Set the necessary parameters, then use Sass::Engine#render .

 require "sass" options = { cache: true, syntax: :sass, style: :compressed, filename: original_file_name, ... } render = Sass::Engine.new(File.read(original_file_name), options).render File.write(output_file_name, render) 
+10
source

This documentation should help:

http://sass-lang.com/documentation/file.SASS_REFERENCE.html

If you have already installed the Sass stone, you can start it from the command line. To use Sass in a ruby ​​script, you need to create a Sass object and then use the functions associated with it.

+1
source

All Articles