From 1969b60987de62204a0d073d84f7514a5fc7adc2 Mon Sep 17 00:00:00 2001 From: Alexander Dubovoy Date: Wed, 3 Apr 2024 14:36:10 +0200 Subject: [PATCH] Add hotwire-livereload This is _optional_ and I would totally understand if we reject it because we don't want to add another dependency. But this PR would add livereload functionality to our Rails templates. I've just tested it and it works almost instantly for CSS and JS changes. This is a feature that we used to have for JS with Webpack but lost with the new importmap setup. We've actually never had it for CSS, so it's even fancier than before (yay!). I thought it would be a nice thing to include since it could speed up development for students during project weeks and also help with teachers doing CSS changes in lectures. I'm honestly not sure we need to explain this to students, but if we wanted to, I could add it into our "front-end setup" guide, which is done in some livecodes, or into the Rails Assets lecture. But I think it's such a simple change (literally adding one gem and running a Terminal command) that it's almost not worth the airtime. --- devise.rb | 8 ++++++++ minimal.rb | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/devise.rb b/devise.rb index 52737da..416542c 100644 --- a/devise.rb +++ b/devise.rb @@ -18,6 +18,10 @@ "\n gem \"dotenv-rails\"" end +inject_into_file "Gemfile", after: "group :development do" do + "\n gem \"hotwire-livereload\"" +end + # Assets ######################################## run "rm -rf app/assets/stylesheets" @@ -195,6 +199,10 @@ def home ######################################## run "curl -L https://raw.githubusercontent.com/lewagon/rails-templates/master/.rubocop.yml > .rubocop.yml" + # Live refresh + ######################################## + run "rails livereload:install" + # Git ######################################## git :init diff --git a/minimal.rb b/minimal.rb index dd449a4..f9401f9 100644 --- a/minimal.rb +++ b/minimal.rb @@ -17,6 +17,10 @@ "\n gem \"dotenv-rails\"" end +inject_into_file "Gemfile", after: "group :development do" do + "\n gem \"hotwire-livereload\"" +end + # Assets ######################################## run "rm -rf app/assets/stylesheets" @@ -120,6 +124,10 @@ ######################################## run "curl -L https://raw.githubusercontent.com/lewagon/rails-templates/master/.rubocop.yml > .rubocop.yml" + # Live refresh + ######################################## + run "rails livereload:install" + # Git ######################################## git :init