Browse Source

add live reload

http://blog.55minutes.com/2013/01/lightning-fast-sass-reloading-in-rails-32/
Felix Niklas 10 years ago
parent
commit
b5f3d35a94
3 changed files with 24 additions and 0 deletions
  1. 6 0
      Gemfile
  2. 11 0
      Guardfile
  3. 7 0
      config/environments/development.rb

+ 6 - 0
Gemfile

@@ -85,6 +85,12 @@ group :development, :test do
     # rest client lib for unit tests
     gem 'faraday'
 
+    # livereload on template changes (html, js, css)
+    gem 'guard', '>= 2.2.2', :require => false
+    gem 'guard-livereload',  :require => false
+    gem 'rack-livereload'
+    gem 'rb-fsevent',        :require => false
+
     # websocket unit tests
 #    gem 'em-websocket-client'
 end

+ 11 - 0
Guardfile

@@ -0,0 +1,11 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'livereload' do
+  watch(%r{app/views/.+\.(erb|haml|slim)$})
+  watch(%r{app/helpers/.+\.rb})
+  watch(%r{public/.+\.(css|js|html)})
+  watch(%r{config/locales/.+\.yml})
+  # Rails Assets Pipeline
+  watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
+end

+ 7 - 0
config/environments/development.rb

@@ -30,4 +30,11 @@ Zammad::Application.configure do
   # Expands the lines which load the assets
   config.assets.debug = true
 
+  # Automatically inject JavaScript needed for LiveReload
+  config.middleware.use(Rack::LiveReload,
+    :min_delay        => 500,    # default 1000
+    :max_delay        => 10_000, # default 60_000
+    :live_reload_port => 67789,  # default 35729
+    :source => :vendored
+  )
 end