Skip to content

Commit

Permalink
Bring in sprockets precompile task
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Aug 24, 2011
1 parent 976b2be commit 5493d22
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions actionpack/lib/sprockets/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,32 @@ namespace :assets do
Rails.application.config.action_controller.perform_caching = true

config = Rails.application.config
assets = config.assets.precompile.dup
assets << {:to => File.join(Rails.public_path, config.assets.prefix)}
Rails.application.assets.precompile(*assets)
env = Rails.application.assets
target = Rails.root.join("public#{config.assets.prefix}")

if env.respond_to?(:each_logical_path)
config.assets.precompile.each do |path|
env.each_logical_path do |logical_path|
if path.is_a?(Regexp)
next unless path.match(logical_path)
else
next unless File.fnmatch(path.to_s, logical_path)
end

if asset = env.find_asset(logical_path)
filename = target.join(asset.digest_path)
mkdir_p filename.dirname
asset.write_to(filename)
asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
end
end
end
else
# TODO: Remove this once we're depending on sprockets beta 15
assets = config.assets.precompile.dup
assets << {:to => target}
env.precompile(*assets)
end
end
end

Expand Down

0 comments on commit 5493d22

Please sign in to comment.