Gemfile:
group :development do
gem 'guard-livereload'
gem "rack-livereload"
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
end
bundle install.
initialize guard:
guard init livereload
It will create the file 'Guardfile':
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
Environment config 'config/environments/development.rb':
Myrails::Application.configure do
config.middleware.use Rack::LiveReload
...
end
Change settings appropriately:
# Specifying Rack::LiveReload options.
config.middleware.use(Rack::LiveReload,
:min_delay => 500, # default 1000
:max_delay => 10_000, # default 60_000
:live_reload_port => 56789, # default 35729
:host => 'myhost.cool.wow',
:ignore => [ %r{dont/modify\.html$} ]
)
read more: https://github.com/johnbintz/rack-livereload.
for Chrome: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en. for Firefox: http://download.livereload.com/2.0.8/LiveReload-2.0.8.xpi.
Run this command in Windows command prompt:
guard
It will run guard that will waiting for a browser connection:
...
06:41:05 - INFO - LiveReload is waiting for a browser to connect.
Open your browser and enable LiveReload. Guard will say something like that:
06:41:05 - INFO - Guard is now watching at 'D:/myprojects/path/site
←[0F[1] guard(main)> 06:41:17 - INFO - Browser connected.
Try change a view and see how browser reloads the page with your changes.
←[0F[1] guard(main)> oading browser: app/views/home/index.html.haml