Skip to content

Instantly share code, notes, and snippets.

@bigfive
Last active August 29, 2015 13:56
Show Gist options
  • Save bigfive/9065827 to your computer and use it in GitHub Desktop.
Save bigfive/9065827 to your computer and use it in GitHub Desktop.
Remove Digests from rails 4 assets
namespace :deploy do
namespace :assets do
task :remove_digests do
run %( cd #{latest_release} && bundle exec rake assets:remove_digests RAILS_ENV=#{rails_env}), :once => true
end
end
end
after 'deploy:assets:precompile', 'deploy:assets:remove_digests'
MyApp::Application.configure do
config.assets.digest = false
end
namespace :assets do
task remove_digests: :environment do
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
regex = /(?<!manifest)(-{1}[a-z0-9]{32}\.{1}){1}/
assets.each do |file|
next if File.directory?(file) || file !~ regex
source = file.split('/')
source.push(source.pop.gsub(regex, '.'))
non_digested = File.join(source)
FileUtils.cp(file, non_digested)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment