@@ -37,13 +37,13 @@ def initialize
3737 # changed since their last package build.
3838 def precache_all ( output_dir = nil , base_url = nil )
3939 output_dir ||= File . join ( PUBLIC_ROOT , Jammit . package_path )
40- cacheable ( :js , output_dir ) . each { |p | cache ( p , 'js' , pack_javascripts ( p ) , output_dir ) }
40+ cacheable ( :js , output_dir ) . each { |p | cache ( p , 'js' , pack_javascripts ( p ) , output_dir , nil , newest_mtime ( p , :js ) ) }
4141 cacheable ( :css , output_dir ) . each do |p |
42- cache ( p , 'css' , pack_stylesheets ( p ) , output_dir )
42+ mtime = newest_mtime ( p , :css )
43+ cache ( p , 'css' , pack_stylesheets ( p ) , output_dir , nil , mtime )
4344 if Jammit . embed_assets
44- cache ( p , 'css' , pack_stylesheets ( p , :datauri ) , output_dir , :datauri )
45+ cache ( p , 'css' , pack_stylesheets ( p , :datauri ) , output_dir , :datauri , mtime )
4546 if Jammit . mhtml_enabled && base_url
46- mtime = Time . now
4747 asset_url = "#{ base_url } #{ Jammit . asset_url ( p , :css , :mhtml , mtime ) } "
4848 cache ( p , 'css' , pack_stylesheets ( p , :mhtml , asset_url ) , output_dir , :mhtml , mtime )
4949 end
@@ -72,6 +72,11 @@ def individual_urls(package, extension)
7272 package_for ( package , extension ) [ :urls ]
7373 end
7474
75+ # Return the modification time of the newest file in the package
76+ def newest_mtime ( package , extension )
77+ package_for ( package , extension ) [ :paths ] . map { |path | File . mtime ( path ) } . max
78+ end
79+
7580 # Return the compressed contents of a stylesheet package.
7681 def pack_stylesheets ( package , variant = nil , asset_url = nil )
7782 @compressor . compress_css ( package_for ( package , :css ) [ :paths ] , variant , asset_url )
0 commit comments