diff --git a/lib/autospec/reload_css.rb b/lib/autospec/reload_css.rb index 8eca22fd920..58e31811f6b 100644 --- a/lib/autospec/reload_css.rb +++ b/lib/autospec/reload_css.rb @@ -25,19 +25,22 @@ class Autospec::ReloadCss def self.run_on_change(paths) if paths.any? { |p| p =~ /\.(css|s[ac]ss)/ } + # todo connect to dev instead? + ActiveRecord::Base.establish_connection s = DiscourseStylesheets.new(:desktop) # TODO: what about mobile? s.compile s.ensure_digestless_file + ActiveRecord::Base.clear_active_connections! paths << "public" + s.stylesheet_relpath_no_digest end paths.map! do |p| hash = nil fullpath = "#{Rails.root}/#{p}" hash = Digest::MD5.hexdigest(File.read(fullpath)) if File.exists?(fullpath) - p = p.sub /\.sass\.erb/, "" - p = p.sub /\.sass/, "" - p = p.sub /\.scss/, "" - p = p.sub /^app\/assets\/stylesheets/, "assets" + p = p.sub(/\.sass\.erb/, "") + p = p.sub(/\.sass/, "") + p = p.sub(/\.scss/, "") + p = p.sub(/^app\/assets\/stylesheets/, "assets") { name: p, hash: hash } end message_bus.publish "/file-change", paths