Sass Ruby Javascript - What's Going on behind the Scene?

I’m learning about Sass at the moment. I read that Sass was written in Ruby, and according to the official website we need to install Ruby on our computer before installing Sass.
Yet our projects are in JS:

  1. I found out there is a JS implementation of Sass - do u recommend using it ? If we do we can simply use Sass as a JS library I guess.
  2. Otherwise, if installing Ruby and Sass for Ruby, I wonder what happens behind the scene. I guess when webpack compiles/interprets everything it will run Ruby Interpreter, will run Sass in it, will provide it our SASS file to be converted to CSS. Is it more or less what’s going on?

Thanks in advance,
Ben

Sass is a pre-processor for CSS. You write your code with the SASS syntax and it gets compiled to CSS, so that the browser can read it.

Try this :slight_smile: http://koala-app.com

SASS was initially developed in Ruby. true/
But you no longer need Ruby to compile sass.

Depending on what build tool you’re using (assuming you’re using Webpack because that’s what you’ve mentioned in your OP), you just need to install the sass-loader (along with style-loader and css-loader)
and import your sass file like

import 'path/to/file.scss';

and in your webpack.config.js add an entry in module.loaders like

{ test: /\.scss$/, exclude: [/node_modules/], loader: 'style-loader!css-loader!scss-loader' },

Alternatively, you may use Ruby like cmd tool. There are plenty of node modules to compile sass to css.

Here is one example

https://www.npmjs.com/package/npm-sass

It has command line API as well as programming API.

Hope this helps

1 Like

Pretty much what @adityaparab said. I think you also have to install node-sass for sass-loader to work.