DEV: Live-reloading of core/plugin CSS alongside preview_theme_id

DEV: Live-reloading of core/plugin CSS alongside preview_theme_id

In development, we track the last requested theme id, and use that to refresh the correct stylesheet targets. The after_action hook runs on every request, but the preview_theme_id parameter is only sent on the initial HTML request. This commit ensures we only fetch the development theme_id on HTML requests

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 069b3c0..7940565 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -64,7 +64,7 @@ class ApplicationController < ActionController::Base
     after_action :remember_theme_id
 
     def remember_theme_id
-      if @theme_ids.present?
+      if @theme_ids.present? && request.format == "html"
         Stylesheet::Watcher.theme_id = @theme_ids.first if defined? Stylesheet::Watcher
       end
     end

GitHub sha: 7c494cc6

1 Like