From e1e7ae2848c913745aa15cb845ee0278590606fc Mon Sep 17 00:00:00 2001 From: Bort Date: Sun, 30 Apr 2023 10:13:54 +0000 Subject: [PATCH] Add livereload to guard --- Guardfile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Guardfile b/Guardfile index 61d48020..8378c587 100644 --- a/Guardfile +++ b/Guardfile @@ -108,3 +108,42 @@ end # watch(/^(app|lib|spec\/support)\/.*\.rb$/) # watch('Gemfile.lock') #end + +guard 'livereload' do + extensions = { + css: :css, + scss: :css, + sass: :css, + js: :js, + coffee: :js, + html: :html, + png: :png, + gif: :gif, + jpg: :jpg, + jpeg: :jpeg, + # less: :less, # uncomment if you want LESS stylesheets done in browser + } + + rails_view_exts = %w(erb haml slim) + + # file types LiveReload may optimize refresh for + compiled_exts = extensions.values.uniq + watch(%r{public/.+\.(#{compiled_exts * '|'})}) + + extensions.each do |ext, type| + watch(%r{ + (?:app|vendor) + (?:/assets/\w+/(?[^.]+) # path+base without extension + (?\.#{ext})) # matching extension (must be first encountered) + (?:\.\w+|$) # other extensions + }x) do |m| + path = m[1] + "/assets/#{path}.#{type}" + end + end + + # file needing a full reload of the page anyway + watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{config/locales/.+\.yml}) +end