From 27d524c5d54de2aad6431b00d5a4b8c4ea208948 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 24 Jan 2024 16:49:04 +0400 Subject: [PATCH] tailwind + rails live reload --- .vscode/extensions.json | 3 ++- Gemfile | 1 + Gemfile.lock | 13 +++++++++++++ README.md | 10 +++++++--- app/views/scores/index.html.erb | 2 +- config/initializers/rails_live_reload.rb | 16 ++++++++++++++++ 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 config/initializers/rails_live_reload.rb diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 1cc1449..4edc49b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,7 @@ "shopify.ruby-lsp", "aki77.rails-db-schema", "yzhang.markdown-all-in-one", - "jgclark.vscode-todo-highlight" + "jgclark.vscode-todo-highlight", + "bradlc.vscode-tailwindcss" ] } \ No newline at end of file diff --git a/Gemfile b/Gemfile index 8b72ea0..adcb860 100644 --- a/Gemfile +++ b/Gemfile @@ -71,6 +71,7 @@ group :development do gem 'ruby-lsp-rails' gem 'amazing_print' + gem 'rails_live_reload' gem 'rails_semantic_logger' end diff --git a/Gemfile.lock b/Gemfile.lock index b3afea1..5090129 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,6 +105,7 @@ GEM ruby2_keywords error_highlight (0.6.0) erubi (1.12.0) + ffi (1.16.3) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.1) @@ -119,6 +120,9 @@ GEM reline (>= 0.3.8) json (2.7.1) language_server-protocol (3.17.0.3) + listen (3.8.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -196,6 +200,11 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) + rails_live_reload (0.3.5) + listen + nio4r + railties + websocket-driver rails_semantic_logger (4.14.0) rack railties (>= 5.1) @@ -210,6 +219,9 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.1.0) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) + ffi (~> 1.0) rdoc (6.6.2) psych (>= 4.0.0) regexp_parser (2.8.3) @@ -329,6 +341,7 @@ DEPENDENCIES pg (~> 1.1) puma (>= 5.0) rails (~> 7.1.2) + rails_live_reload rails_semantic_logger rainbow rubocop diff --git a/README.md b/README.md index 1648a2a..f4bd33b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ sudo apt install -y build-essential ruby-dev libpq-dev libyaml-dev 2>/dev/null grep -q GEM_HOME $HOME/.bashrc || printf "export GEM_HOME=$HOME/.ruby\nexport PATH=\$PATH:\$GEM_HOME/bin\n" >> $HOME/.bashrc && source $HOME/.bashrc [[ -f $HOME/.gemrc ]] || echo 'gem: --no-document' >> $HOME/.gemrc -gem install rails bundler +gem install bundler bundle install ``` @@ -44,6 +44,10 @@ end * [x] Ruby-lsp-rails * [x] Ruby Db Schema * [x] Markdown All in One -* [ ] TODO Highliter - * [ ] run ` rails notes` to show up any TODO or FIXME +* [x] TODO Highliter + * [x] run ` rails notes` to show up any TODO or FIXME +* [x] Tailwind CSS + * [x] plugin for completion +* [x] Rails Live Reload + * [x] compliant with Tailwind diff --git a/app/views/scores/index.html.erb b/app/views/scores/index.html.erb index 9d53c06..4f03f18 100644 --- a/app/views/scores/index.html.erb +++ b/app/views/scores/index.html.erb @@ -8,7 +8,7 @@ <%= link_to "New score", new_score_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> -
+
<%= render @scores %>
diff --git a/config/initializers/rails_live_reload.rb b/config/initializers/rails_live_reload.rb new file mode 100644 index 0000000..2de780d --- /dev/null +++ b/config/initializers/rails_live_reload.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +if defined?(RailsLiveReload) + RailsLiveReload.configure do |config| + # config.url = "/rails/live/reload" + + # Default watched folders & files + config.watch %r{app/views/.+\.(erb|haml|slim)$} + config.watch %r{(app|vendor)/(assets|javascript)/\w+/(.+\.(css|js|html|png|jpg|ts|jsx)).*}, reload: :always + + # USEFUL for tailwind changes!!!! + config.watch %r{app/assets/builds/tailwind.css}, reload: :always + + config.enabled = Rails.env.development? + end +end