Sunteți pe pagina 1din 15

Recommended by Adrian Sandu, Sean PJPGR Doran, and 59 others

Ricardo Zea
Full‐Stack Designer http://ricardozea.design — Smashing Magazine Author: https://www.smashingmagazine.…
May 12, 2014 · 7 min read

[Sass] For Beginners: The


Friendliest Guide About
INSTALLING and USING Sass
on Windows
The simplest and most detailed guide about how to install
and use Sass you’ll ever read!

Before You Start Reading:

If you’re a beginner in Sass, this detailed tutorial is for you. I really hope
you enjoy it, I spent a few days working on it to create a compelling and
useful message.

Please recommend it at the end if you found it useful 😊 — Thanks!

What makes this guide diµerent?


I remember almost 2 years ago (today being 5/8/2014) I looked all
over the web for a simple guide, with simple steps, in “human”
language to help me install Sass. There was NOTHING. Well, actually
there was this one website (I can’t even find it now anymore) that had a
very, very rough list of how to do it, but yet it was the ‘friendliest’ of
everything else I came across.

After trying to install Sass three times in a span of about 3-4 months, I
was finally able to “crack the code”. Now, here I am showing you how to
do it 😉.

So what makes this guide different from aaaaalll other guides out
there? It’s different because I’m going to explain it to you the way I
would’ve liked to have seen it explained to me back then, when I had no
clue about command line crap (and I still don’t to be honest).

This is a:

A. Simple Guide
B. With simple Steps
C. In human language

Here we go 🚀!

Steps to Installing Sass on Windows


Steps to Installing Sass on Windows
(versions 7/8/10)
1. Download the Ruby installer: http://rubyinstaller.org/downloads/
— Look for the version with (x64) on it.
Edit (12/8/2016) — I’ve confirmed that Sass works fine with Ruby
2.3.3 (x64) at the moment of this edit.
̶Ed̶ i̶ t̶ ̶ (̶ 4̶ /̶ 1̶ 4̶ /̶ 2̶ 0̶ 1̶ 5̶ )̶ ̶  ̶ — ̶ M
̶ a̶ k̶ e̶ ̶ s̶ u̶ r̶ e̶ ̶ t̶ h̶ e̶ ̶ R
̶ u̶ b̶ y̶ ̶ i̶ n̶ s̶ t̶ a̶ l̶ l̶ e̶ r̶ ̶ i̶ s̶ ̶ v̶ e̶ r̶ s̶ i̶ o̶ n̶ ̶ 1̶ .̶ 9̶ x̶ .̶ ̶ I̶ t̶ ’̶ s̶ ̶ b̶ e̶ e̶ n̶ ̶
m
̶ y̶ ̶ e̶ x̶ p̶ e̶ r̶ i̶ e̶ n̶ c̶ e̶ ̶ t̶ h̶ a̶ t̶ ̶ u̶ s̶ i̶ n̶ g̶ ̶ a̶ n̶ y̶ ̶ o̶ f̶ ̶ t̶ h̶ e̶ ̶ 2̶ .̶ x̶ ̶ v̶ e̶ r̶ s̶ i̶ o̶ n̶ s̶ ,̶ ̶ S
̶ a̶ s̶ s̶ ̶ d̶ o̶ e̶ s̶ n̶ ’̶ t̶ ̶ w
̶ o̶ r̶ k̶ .̶ ̶ I̶ f̶ ̶
a̶ n̶ y̶ o̶ n̶ e̶ ̶ c̶ a̶ n̶ ̶ c̶ o̶ n̶ f̶ i̶ r̶ m
̶ ̶ o̶ t̶ h̶ e̶ r̶ w
̶ i̶ s̶ e̶ ,̶ ̶ p̶ l̶ e̶ a̶ s̶ e̶ ̶ l̶ e̶ t̶ ̶ m
̶ e̶ ̶ k̶ n̶ o̶ w
̶ ̶ i̶ n̶ ̶ t̶ h̶ e̶ ̶ c̶ o̶ m
̶ m
̶ e̶ n̶ t̶ s̶ .̶ ̶ T
̶ h̶ a̶ n̶ k̶ s̶ .̶ ̶

WTF is Ruby? 😕
Ruby is the technology or programming language Sass is built on. So you
need to install Ruby first so Sass can then run on top of it. 😌

2. Open the Command Line (CMD)


Tip!: Press Windows Key + R and type: CMD, then press Enter.
The almighty Command Line (CMD) will appear:
Command Line
(CMD) in Windows

3. Type the following command in the CMD (it doesn’t matter which
folder you’re in):

gem install sass
Command to install Sass

WTF is a gem 😕?
A gem is piece of software or app made to run on Ruby. It’s like… installing
an addon on Firefox or an extension on Chrome 😌.

It’ll take a few seconds to install Sass. At the end you’ll see this (the Sass
version may very well be different now though):

Successfully installed sass­3.3.7
1 gem installed
Installing ri documentation for sass­3.3.7…
Installing RDoc documentation for sass­3.3.7…

Here’s a screenshot of what you’ll see in the CMD:


Result of successfully installing Sass

That’s it! Sass is now installed on your machine 🎉!

Yeah, I know it looks “doh!” and simple but believe me, there were no
screenshots of anything back then and most of the installation tutorials
were for Macs.

So hopefully someone can find these steps useful and clear as they need
to be.

Check the “PATH” if you’re having issues


executing Ruby
Sometimes, for some unknown reason, Ruby doesn’t get properly
installed in your PATH. If this happens to you, check your PATH to
make sure the folder to Ruby is listed there.
Environment Variables dialog box in Windows showing the PATH to Ruby’s executable.

Don’t know what the PATH is? No problem, read this post I created
exactly for this moment 😉: The effin’ PATH demystified (Windows).

…Or Reinstall Ruby


If you don’t know how to edit the PATH, relax. Just reinstall Ruby and
make sure you have the ‘Add Ruby executables to your PATH’ option
checked:
Ruby installation wizard. Make sure ‘Add Ruby executables to your PATH’ option checked.

. . .

Steps to use Sass
Ok, what I’m about to show you is COMPLETELY different than what
any other Sass tutorial out there tells you to do.

Why? Because most of those tutorials complicate things too much.

1. Create a /Demo folder anywhere on your drive


Like this:
¸Demo folder created in my hard drive.

2. Inside that folder create two sub folders: /css and /scss
Like this:

¸css and ¸scss folders.

3. Create a .scss file


Go into the /scss folder and create a file called: demo-styles.scss
Like this:
demo-styles.scss Ûle.

Notice the file extension .scss? This is your Sass file 😊. And yes, right
now there’s nothing in it, it’s empty.

4. Go back to the CMD line for a minute


In the CMD line you need to go to the /Demo folder.
Tip!: The easiest way to go the /Demo folder is by dragging & dropping
from your file manager into the CMD window, like this:
Drag & drop the ¸Demo folder into the CMD.

I. In the CMD type: cd(space), yes, a space after “cd”.


“cd” means Change Directory.

II. From your file manager drag & drop the /Demo folder into the CMD
window.

III. Press Enter

IV. You should be in the /Demo folder now

Note: In my animated GIF above I used my Z: drive to create the /Demo


folder, that’s why you see an extra step where I have to type ‘z: + Enter’ in
order to go to that drive.

And, here come the cool parts:

Make Sass watch your SCSS ½les and make


it compile the CSS
5. Make Sass “watch” your /scss and /css folders
Type this in the CMD:

sass ­­watch scss:css

Like this:

Make Sass “watch” the ¸scss an ¸css folders.


That’s it. You are now using Sass 😁!

WTF is the “--watch” command 😕?


Actually, the “--watch” command is not a “command”. It’s called a flag.

The “--watch” flag tells Sass to “pay attention” to the folders /scss and
/css, so when you make changes to the .scss file (demo-styles.scss) Sass will
detect the change and compile the SCSS file into the final CSS file you’re
going to use on your website or app 👍.

All tutorials I’ve read make you watch specific files, like this:

sass ­­watch styles.scss:styles.css

…which is Ok. I just think that watching folders is easier and makes
more sense because you’re watching ALL FILES in both directories
rather than specific ones, and saves you having to type too much in the
CMD as well.

6. Edit the .scss file and watch Sass compile it into a .css file

Like this:
Sass compiling a .scss Ûle to .css

I. Open your CSS editor (I use Sublime Text)

II. Open the file demo-styles.scss

III. Add some CSS to it

IV. Save the demo-styles.scss file


V. Verify in your CMD that the compiling was successful

VI. Open your demo-styles.css and enjoy your new creation

You now have leveled up by knowing how to use Sass☺.

Note: As you can see I’m writing basic CSS, not Sass because what I’m
trying to show you here is how the .css file is compiled.

Final Words
Yeah, post a little longer than others but I think the clarity in the steps
makes it worth it.

As far as how to write Sass, there are plenty of articles out there, I can
recommend this one: Beginner Guides & Tutorials on Sass and
Compass and this one: Getting Started with Sass.

If you’re interested in another ‘simple & friendly’ post about the pure
basics of Sass, drop me a message.

Or if you still need help, same thing, drop me a message on Twitter, or


my personal website, I’d be glad to help.

Thanks for reading 😎!

If you found this post valuable, don’t forget to Recommend it


below :). Thanks!


Ricardo.

S-ar putea să vă placă și