Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Created February 21, 2014 08:46
Show Gist options
  • Select an option

  • Save stevenyap/9130821 to your computer and use it in GitHub Desktop.

Select an option

Save stevenyap/9130821 to your computer and use it in GitHub Desktop.
Live Reload to test your CSS instantly in browsers

Setup Steps

# Gemfile
group :development do
  gem 'guard',              :require => false
  gem 'guard-livereload',   :require => false
  gem 'rack-livereload'
end

# config/environments/development.rb

YOURAPPLICATIONNAME::Application.configure do
  # Automatically inject JavaScript needed for LiveReload
  config.middleware.use Rack::LiveReload
end

# monkey patch to make Rack::LiveReload work for IE
# Not needed anymore if your IE > 9 and gem all updated
module Rack
  class LiveReload
    class ProcessingSkipAnalyzer
      def bad_browser?
        false
      end
    end
  end
end

Bundle and init

  • Run bundle install
  • Run guard init livereload

To use

  • Start server first: rails s
  • Start guard for livereload only: guard -P livereload
  • That's it!

Tip: You need to manually CMD + s to save your CSS in order for the reload to work (in rubymine)

Trouble-shooting

  • Try running bundle update to ensure you have all the latest gems
  • Make sure IE has installed Flash player
  • It seems to work well for IE if you are using POW instead of webricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment