mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
be a bit more forgiving with reloader
This commit is contained in:
parent
f555bbb416
commit
b916108927
1 changed files with 7 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue