Rails 4 has changed the way assets are fingerprinted (for browser cache busting):
Old Strategy: application.css?12345
Rails 3.2: application-12345.css and application.css
Rails 4.0: application-12345.css
While this makes perfect sense, it's a problem if the stylesheets are used by another service (in our case Zendesk). This external site needs the CSS from the Rails app, but it doesn't know the fingerprint (aka: digest).
Is there a way to compile all assets both with and without fingerprint? Or maybe another approach to tackle this?
I've written a rake task to get the un-fingerprinted files à la Rails 3.2 back:
namespace :assets do
desc "Create symlinks without cache busting digest"
task :create_symlinks_without_digest => :environment do
Dir.glob(Rails.root.join('public', 'assets', '**', '*')).each do |item|
if File.file?(item) && item.match(/-[a-f0-9]{32}/)
FileUtils.ln_s Pathname(item).basename, item.sub(/-[a-f0-9]{32}/, '')
end
end
end
end
来源:https://stackoverflow.com/questions/23544904/rails-4-asset-pipeline-compile-both-with-and-without-fingerprint