require 'fileutils'

desc 'Compile all the assets named in config.assets.precompile with and without appended digests'
task 'assets:precompile' do
  digest = /\-[0-9a-f]{32}\./

  assets = Dir['public/assets/**/*'].select { |asset| asset =~ digest }.
    map { |asset| [asset, asset.sub(digest, '.')] }

  assets.each do |asset, nondigest|
    if !File.exist?(nondigest) || File.mtime(asset) > File.mtime(nondigest)
      FileUtils.cp(asset, nondigest, verbose: true)
    end
  end
end

require 'fileutils'

desc 'Compile all the assets named in config.assets.precompile with and without appended digests'
task 'assets:precompile' do
  assets = JSON.parse(File.read('public/assets/manifest.json'))['assets']

  assets.each do |asset, digested_asset|
    FileUtils.cp("public/assets/#{digested_asset}", "public/assets/#{asset}", verbose: true)
  end
end

Use the manifest to replace the most recent files
Use the manifest to replace the most recent files
