From 05adf9a5346e529b03469b560916bed439f1a8ee Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 27 Jun 2018 18:44:15 +0200 Subject: [PATCH] Enable Rack::LiveReload on demand to avoid JS errors. --- Gemfile | 2 +- config/environments/development.rb | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 17be6b301..b7a61f748 100644 --- a/Gemfile +++ b/Gemfile @@ -144,7 +144,7 @@ group :development, :test do # livereload on template changes (html, js, css) gem 'guard', require: false gem 'guard-livereload', require: false - gem 'rack-livereload' + gem 'rack-livereload', require: false gem 'rb-fsevent', require: false # auto symlinking diff --git a/config/environments/development.rb b/config/environments/development.rb index 501ea94e4..90b61895d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -31,15 +31,17 @@ Rails.application.configure do #config.assets.debug = true config.assets.debug = false - # Automatically inject JavaScript needed for LiveReload - config.middleware.insert_after( - ActionDispatch::Static, - Rack::LiveReload, - no_swf: true, - min_delay: 500, # default 1000 - max_delay: 10_000, # default 60_000 - live_reload_port: 35_738 - ) + if defined?(Rack::LiveReload) + # Automatically inject JavaScript needed for LiveReload + config.middleware.insert_after( + ActionDispatch::Static, + Rack::LiveReload, + no_swf: true, + min_delay: 500, # default 1000 + max_delay: 10_000, # default 60_000 + live_reload_port: 35_738 + ) + end # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params.