In Rails 3 there was a rake assets:precompile:nodigest task which was compiling assets and writing them without the digest part in /public/assets directory. In Rails 4 this
Thank you Dylan Markow, I follow his answer, but I found that there are several versions of an asset (e.g. application-0a*.css, application-9c*.css, ...) when using Capistrano so that latest one should be non-digested. Here the logic is:
namespace :my_app do
task non_digested: :environment do
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
regex = /(? c[:mtime]
candidates[non_digested] = {orig: file, mtime: file_mtime}
end
end
# genearate
for non_digested, val in candidates do
FileUtils.cp(val[:orig], non_digested)
end
end
end
Rake::Task['assets:precompile'].enhance do
Rake::Task['my_app:non_digested'].invoke
end
As wells as, I applied 907th's regex comment, and add hook let this task executes after precompile.