mirror of
https://github.com/edcommonwealth/ecp.org.git
synced 2026-03-07 13:38:13 -08:00
Add guard-livereload to automatically reload the browser when files change
This commit is contained in:
parent
11f413eb84
commit
98b9134779
3 changed files with 103 additions and 6 deletions
10
Gemfile
10
Gemfile
|
|
@ -53,15 +53,12 @@ gem 'bootsnap', require: false
|
|||
|
||||
gem 'mail_form'
|
||||
|
||||
group :development, :test do
|
||||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
||||
gem 'debug', platforms: %i[mri mingw x64_mingw]
|
||||
end
|
||||
|
||||
group :development do
|
||||
# Use console on exceptions pages [https://github.com/rails/web-console]
|
||||
gem 'guard'
|
||||
gem 'guard-livereload', '~> 2.5', require: false
|
||||
gem 'rack-livereload'
|
||||
gem 'web-console'
|
||||
|
||||
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
|
||||
# gem "rack-mini-profiler"
|
||||
|
||||
|
|
@ -70,6 +67,7 @@ group :development do
|
|||
end
|
||||
|
||||
group :development, :test do
|
||||
gem 'debug', platforms: %i[mri mingw x64_mingw]
|
||||
gem 'factory_bot_rails'
|
||||
gem 'rspec-rails'
|
||||
end
|
||||
|
|
|
|||
44
Gemfile.lock
44
Gemfile.lock
|
|
@ -70,6 +70,7 @@ GEM
|
|||
bootsnap (1.16.0)
|
||||
msgpack (~> 1.2)
|
||||
builder (3.2.4)
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.2.0)
|
||||
crass (1.0.6)
|
||||
cssbundling-rails (1.1.2)
|
||||
|
|
@ -79,14 +80,36 @@ GEM
|
|||
irb (>= 1.5.0)
|
||||
reline (>= 0.3.1)
|
||||
diff-lcs (1.5.0)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
erubi (1.12.0)
|
||||
eventmachine (1.2.7)
|
||||
factory_bot (6.2.1)
|
||||
activesupport (>= 5.0.0)
|
||||
factory_bot_rails (6.2.0)
|
||||
factory_bot (~> 6.2.0)
|
||||
railties (>= 5.0.0)
|
||||
ffi (1.15.5)
|
||||
formatador (1.1.0)
|
||||
globalid (1.1.0)
|
||||
activesupport (>= 5.0)
|
||||
guard (2.18.0)
|
||||
formatador (>= 0.2.4)
|
||||
listen (>= 2.7, < 4.0)
|
||||
lumberjack (>= 1.0.12, < 2.0)
|
||||
nenv (~> 0.1)
|
||||
notiffany (~> 0.0)
|
||||
pry (>= 0.13.0)
|
||||
shellany (~> 0.0)
|
||||
thor (>= 0.18.1)
|
||||
guard-compat (1.2.1)
|
||||
guard-livereload (2.5.2)
|
||||
em-websocket (~> 0.5)
|
||||
guard (~> 2.8)
|
||||
guard-compat (~> 1.0)
|
||||
multi_json (~> 1.8)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.12.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
io-console (0.6.0)
|
||||
|
|
@ -97,9 +120,13 @@ GEM
|
|||
activesupport (>= 5.0.0)
|
||||
jsbundling-rails (1.1.1)
|
||||
railties (>= 6.0.0)
|
||||
listen (3.8.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
loofah (2.19.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
lumberjack (1.2.8)
|
||||
mail (2.8.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
net-imap
|
||||
|
|
@ -113,6 +140,8 @@ GEM
|
|||
mini_mime (1.1.2)
|
||||
minitest (5.17.0)
|
||||
msgpack (1.6.0)
|
||||
multi_json (1.15.0)
|
||||
nenv (0.3.0)
|
||||
net-imap (0.3.4)
|
||||
date
|
||||
net-protocol
|
||||
|
|
@ -125,11 +154,19 @@ GEM
|
|||
nio4r (2.5.8)
|
||||
nokogiri (1.14.2-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
notiffany (0.1.3)
|
||||
nenv (~> 0.1)
|
||||
shellany (~> 0.0)
|
||||
pg (1.4.5)
|
||||
pry (0.14.2)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
puma (5.6.5)
|
||||
nio4r (~> 2.0)
|
||||
racc (1.6.2)
|
||||
rack (2.2.6.2)
|
||||
rack-livereload (0.3.17)
|
||||
rack
|
||||
rack-test (2.0.2)
|
||||
rack (>= 1.3)
|
||||
rails (7.0.4.2)
|
||||
|
|
@ -159,6 +196,9 @@ GEM
|
|||
thor (~> 1.0)
|
||||
zeitwerk (~> 2.5)
|
||||
rake (13.0.6)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
reline (0.3.2)
|
||||
io-console (~> 0.5)
|
||||
rspec-core (3.12.1)
|
||||
|
|
@ -178,6 +218,7 @@ GEM
|
|||
rspec-mocks (~> 3.11)
|
||||
rspec-support (~> 3.11)
|
||||
rspec-support (3.12.0)
|
||||
shellany (0.0.1)
|
||||
sprockets (4.2.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (>= 2.2.4, < 4)
|
||||
|
|
@ -213,11 +254,14 @@ DEPENDENCIES
|
|||
cssbundling-rails
|
||||
debug
|
||||
factory_bot_rails
|
||||
guard
|
||||
guard-livereload (~> 2.5)
|
||||
jbuilder
|
||||
jsbundling-rails
|
||||
mail_form
|
||||
pg (~> 1.1)
|
||||
puma (~> 5.0)
|
||||
rack-livereload
|
||||
rails (~> 7.0.4)
|
||||
rspec-rails
|
||||
sprockets-rails
|
||||
|
|
|
|||
55
Guardfile
Normal file
55
Guardfile
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# A sample Guardfile
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
## Uncomment and set this to only include directories you want to watch
|
||||
# directories %w(app lib config test spec features) \
|
||||
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
||||
|
||||
## Note: if you are using the `directories` clause above and you are not
|
||||
## watching the project directory ('.'), then you will want to move
|
||||
## the Guardfile to a watched dir and symlink it back, e.g.
|
||||
#
|
||||
# $ mkdir config
|
||||
# $ mv Guardfile config/
|
||||
# $ ln -s config/Guardfile .
|
||||
#
|
||||
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
||||
|
||||
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>[^.]+) # path+base without extension
|
||||
(?<ext>\.#{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
|
||||
Loading…
Add table
Add a link
Reference in a new issue