Lessons: 20Length: 1.9 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.1 Install Method 1: The Command Line

Sass is written with Ruby. This is a programming language. So to use Sass, you need to have Ruby installed. Now, if you're using a Mac, then you already have Ruby pre-installed. You don't have to do anything. However, if you are using Windows, the easiest way to install Ruby is with Ruby installer. If you are using Linux, you can find details in the official Ruby documentation. I am using a Mac, so I already have it installed. Now, the next thing you need to do is open the terminal or the command line. In Mac OS and Linux, it's called the terminal. In Windows, it's called the command prompt. Before we decide whether or not we should install Sass, we need to check if we don't have it installed already. For this, you need to type in the command line sass space -v, if you will get aversion number then you already have Sass installed. However if you get an error message then you need to install it. To do that, type gem install sass. If you get an error saying that you don't have enough permissions, you need to type sudo gem install sass. This basically means, install as admin. It will ask for your admin password and should successfully install the package. Now to make sure you installed it correctly, go ahead and type sas-v again in the terminal. Now it should give you the version number. That's how you install Sass via the command line. Now how do you actually compile Sass to CSS? Well, here's a demo Sass file. It has the extension of .css and it's inside a folder called project on my desktop. First thing you'll need to do is navigate to your working folder. To do that, use the cd commands, or change directory. So, in our case it's cd, space and then the path to your folder. And once you are in the project folder, you simply type sass watch master.scss:master.css. So you're basically telling Sass to watch for the master.css file, and to compile it to master.css. This will, of course, compile the Sass file, and also start a watch action that will keep an eye on the master.css file and then as soon as that see the change it will recompile it. And that's how you compiles Sass by using the command line. Now, If you don't fancy the command line, there are some third party absent services that can compile Sass for you, automatically. You learn about those in the next lesson.

Back to the top