Note that this is not specific to Rails projects. I work with Drupal themes.
This will enable Sass+Compass with LiveReload through Guard. (Guard screen cast)
You will also need the Browser Extension for LiveReload.
If you prefer going through a GUI, that option is available.
Place the Gemfile
and .GuardFile
into your home folder.
Open terminal and type:
$ gem update --system
$ gem install bundler
$ bundle
The above commands might require sudo
if your using the default ruby
installation on Mac OSX. You will also need to install Developer Tools which is free from the AppStore. I’m using a HomeBrew installation. RVM is another option. Both do not require sudo
.
UPDATE: You can now use Command Line Tools for Xcode instead of the full Developer Tools.
Then cd
to your theme and compass init
and configure the generated config.rb
file. Here's an example:
# http://compass-style.org/help/tutorials/configuration-reference/
http_path = "/"
css_dir = "styles"
sass_dir = "styles"
javascripts_dir = "scripts"
images_dir = "images"
fonts_dir = "fonts"
project_type = :stand_alone
environment = :development
output_style = :nested
relative_assets = true
disable_warnings = false
line_comments = true
preferred_syntax = :scss
In your theme folder, start the Guard, enable the Browser plug-in and start editing.
$ guard
Using compass watch
or the equivalent in Sass is not required since it is being handled through Guard::Compass. A huge plus of Guard is that it uses a single observer and the extensions handle specific details like communicating with the browser (LiveReload) or telling Compass to compile. Any modifications will be directed to specific Guard extensions based on watch
rules.