Getting Sassy with Sass, CSS's wiser Uncle.
CSS can be painful to write and even worse to maintain...
"as I tack on line 1000 of a css file in fear of breaking something otherwise"
I think even those that truely love language would agree. If you lean towards the front end of web development CSS is unavoidable. CSS shouldn't be this painful, we as programmers/developers/hackers/code monkies should not shy away from making things look nice.
After all who do you write programs for....other people, normally not programmers.As far as anyone else is concerned the UI is the program. They don't care how nicely you've abstracted functionality, how that new method you tried out worked or if you have clear comments. They want to interact with the program.
There is a better way
SASS: Syntactically Awesome Style Sheets:
This language makes sense, it organizes things effectively and clearly. Sass is a scripting language that is interpreted or compiled into Cascading Style Sheets (CSS). SassScript is the scripting language itself.
It's been around a while in web dev terms (since 2006), but has really gained popularity over the last few years and is currently used and supported in many web development technologies such as Bootstrap, Jekyll and is supported in the 2017 Adobe Dreamweaver (yes it still exsists).
So let's get started, I'll be using Linux this will probably work on Mac but will obviously not on Windows.
We have to have some way to compile the SassScript, for that we need
Ruby a programming language that gained popularity with
Rails a server side framework written in
I use a RVM which stands for Ruby version manager... I'm sure you can guess what it does. This will keep things neat and tidy.
Follow the download instructions for
RVM. After that run:
rvm install <the_ruby_version_you_want>
rvm install 2.3.1
rvm use 2.3.1
rvm rubygems latest -- this is a little like
npm, it makes installing packages ( or gems ) for
now we install
compass an open-source CSS Authoring Framework. This will allow us to turn our Sass files into CSS, you may or may not need sudo here..
gem update --system
gem install compass
we should probrably install
Sass at somepoint:
gem install sass
We are ready to roll:
set up a
config.rb file in your project root to let compass know what's up, here's a sample to get you started:
For more details on configuration check out the compass docs
be sure to set your paths correctly this example project looks like this:
index.html | css/styles.css | |--sass/ | |-- partials/ # Partials do a quick google search for "Sass partials" | | |-- _base.sass # imports for all mixins + global project variables | |-- styles.scss | |--js/ |--images/ |--fonts/ |
next run either
compass watch to watch for changes to
Sass files and auto compile to
CSS or manually run
compass compile to turn your
Well I didn't really cover
Sass here but at least your ready to go!
Head over to http://thesassway.com/ for some great tutorials. Check out the
Advanced section to get your mind blown.
You can always try
Sass at somewhere like Codepen without all the overhead. Simply choose
Sass in the
CSS preprocessors tab under settings.
It really is worth a little set up for a massive longterm gain. I've had great fun learning Sass and hope to dive a little deeper this year.
So i'll prob be posting about how to use Sass at some point in the future.