Fix the file watcher to correctly use relative paths, to ignore files we don't care about, and have a find_new_files method that works like reload_path, but only touches previously-unknown files. This all ends up speeding up the build by a lot.

This commit is contained in:
Ben Hollis 2012-04-23 01:12:52 -07:00
parent 9024de85d8
commit a4fcb4d939
2 changed files with 27 additions and 3 deletions

View file

@ -196,19 +196,25 @@ module Middleman::Cli
sort_order = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .ico .woff .otf .ttf .eot .js .css)
# Pre-request CSS to give Compass a chance to build sprites
puts "== Prerendering CSS" if @app.logging?
@app.sitemap.resources.select do |resource|
resource.ext == ".css"
end.each do |resource|
Middleman::Cli::Build.shared_rack.get(resource.destination_path.gsub(/\s/, "%20"))
end
puts "== Checking for Compass sprites" if @app.logging?
# Double-check for compass sprites
@app.files.reload_path(File.join(@app.source_dir, @app.images_dir))
@app.files.find_new_files(File.join(@app.source_dir, @app.images_dir))
# Sort paths to be built by the above order. This is primarily so Compass can
# find files in the build folder when it needs to generate sprites for the
# css files
puts "== Building files" if @app.logging?
resources = @app.sitemap.resources.sort do |a, b|
a_idx = sort_order.index(a.ext) || 100
b_idx = sort_order.index(b.ext) || 100