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