Last active
August 29, 2015 13:56
-
-
Save bigfive/9065827 to your computer and use it in GitHub Desktop.
Remove Digests from rails 4 assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp::Application.configure do | |
config.assets.digest = false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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