aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/sprockets/assets.rake
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/sprockets/assets.rake')
-rw-r--r--actionpack/lib/sprockets/assets.rake27
1 files changed, 5 insertions, 22 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake
index 81223b7ead..7241671db0 100644
--- a/actionpack/lib/sprockets/assets.rake
+++ b/actionpack/lib/sprockets/assets.rake
@@ -1,6 +1,9 @@
namespace :assets do
desc "Compile all the assets named in config.assets.precompile"
task :precompile do
+ # let rails know we're precompiling assets
+ ENV["RAILS_ASSETS_PRECOMPILE"] = 'true'
+
# We need to do this dance because RAILS_GROUPS is used
# too early in the boot process and changing here is already too late.
if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
@@ -20,30 +23,10 @@ namespace :assets do
config = Rails.application.config
env = Rails.application.assets
target = Pathname.new(File.join(Rails.public_path, config.assets.prefix))
- manifest = {}
manifest_path = config.assets.manifest || target
- config.assets.precompile.each do |path|
- env.each_logical_path do |logical_path|
- if path.is_a?(Regexp)
- next unless path.match(logical_path)
- elsif path.is_a?(Proc)
- next unless path.call(logical_path)
- else
- next unless File.fnmatch(path.to_s, logical_path)
- end
-
- if asset = env.find_asset(logical_path)
- asset_path = config.assets.digest ? asset.digest_path : logical_path
- manifest[logical_path] = asset_path
- filename = target.join(asset_path)
-
- mkdir_p filename.dirname
- asset.write_to(filename)
- asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
- end
- end
- end
+ static_compiler = Sprockets::StaticCompiler.new(env, target, :digest => config.assets.digest)
+ manifest = static_compiler.precompile(config.assets.precompile)
File.open("#{manifest_path}/manifest.yml", 'wb') do |f|
YAML.dump(manifest, f)