Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RailsLiveReload #2628

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ if Gem.ruby_version >= Gem::Version.new("3.1.0")
end

gem "web-console", "~> 4.2", group: :development

gem "rails_live_reload", "~> 0.3.5"
13 changes: 13 additions & 0 deletions config/initializers/rails_live_reload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

if defined?(RailsLiveReload)
RailsLiveReload.configure do |config|
# Default watched folders & files
config.watch %r{app/views/.+\.(erb)$}
config.watch %r{(app|vendor)/(assets|javascript)/\w+/(.+\.(s?css|coffee|js|html|png|jpg)).*}, reload: :always

# More examples:
config.watch %r{app/(helpers|components|decorators)/.+\.rb}, reload: :always
config.watch %r{config/locales/.+\.yml}, reload: :always
end
end
5 changes: 5 additions & 0 deletions lib/alchemy/dev_support/live_reload_watcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Alchemy
class LiveReloadWatcher < RailsLiveReload::Watcher
def root = Alchemy::Engine.root
end
end
6 changes: 6 additions & 0 deletions lib/alchemy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class Engine < Rails::Engine
Alchemy.user_class.stampable(stamper_class_name: Alchemy.user_class.name)
end
end

if defined?(RailsLiveReload) && Rails.env.development?
require "alchemy/dev_support/live_reload_watcher"

Alchemy::LiveReloadWatcher.init
end
end

initializer "alchemy.webp-mime_type" do
Expand Down
4 changes: 1 addition & 3 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# frozen_string_literal: true

Rails.application.routes.draw do
get "/login" => "login#new", :as => "login"

mount JasmineRails::Engine => "/specs" if defined?(JasmineRails)

get '/login' => 'login#new', as: 'login'
namespace :ns do
resources :locations, only: :index
end
Expand Down
Loading