Merge pull request #1695 from johnnyshields/fix-sass-livereload-master
Fix SASS partial live reloading
This commit is contained in:
commit
b0582bcebf
1 changed files with 21 additions and 0 deletions
|
@ -222,6 +222,8 @@ module Middleman
|
|||
|
||||
return if updated.empty? && removed.empty?
|
||||
|
||||
updated |= find_related_files(updated + removed)
|
||||
|
||||
update(updated.map { |s| Pathname(s) }, removed.map { |s| Pathname(s) })
|
||||
end
|
||||
|
||||
|
@ -304,5 +306,24 @@ module Middleman
|
|||
|
||||
::Middleman::SourceFile.new(Pathname(relative_path), path, @directory, types)
|
||||
end
|
||||
|
||||
# Finds files which should also be considered to be dirty when
|
||||
# the given file(s) are touched.
|
||||
#
|
||||
# @param [Array] files The original touched file paths.
|
||||
# @return [Array] All related file paths, not including the source file paths.
|
||||
Contract ArrayOf[String] => ArrayOf[String]
|
||||
def find_related_files(files)
|
||||
files.map do |file|
|
||||
related_files = []
|
||||
|
||||
# If any SASS file changes, reload all non-partials
|
||||
if file =~ /\.(sass|scss)$/
|
||||
related_files |= Dir[File.join(@directory, app.config[:css_dir], '**/[^_]*.{scss,sass}')]
|
||||
end
|
||||
|
||||
related_files
|
||||
end.flatten.uniq - files
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue