Created
March 19, 2015 17:23
-
-
Save rubysolo/3da38a76a7832a3214b9 to your computer and use it in GitHub Desktop.
create non-digested assets
This file contains hidden or 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 nondigest: :"assets:environment" do | |
logger = Logger.new($stderr) | |
asset_path = Rails.root.join('public', MyRailsApp::Application.config.assets.prefix.gsub(%r{^/}, '')) | |
manifest_path = Dir.glob(asset_path.join('manifest-*.json')).first | |
manifest_data = JSON.load(File.new(manifest_path)) | |
manifest_data["assets"].each do |logical_path, digested_path| | |
full_digested_path = asset_path.join(digested_path) | |
full_nondigested_path = asset_path.join(logical_path) | |
logger.info "[assets] Copying to #{ full_nondigested_path }..." | |
FileUtils.copy_file full_digested_path, full_nondigested_path, true | |
end | |
end | |
end | |
if ENV['RAILS_ENV'] == 'test' | |
Rake::Task['assets:precompile'].enhance do | |
Rake::Task['assets:nondigest'].invoke | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment