Browse files

Set default location of manifest with config.assets.manifest

  • Loading branch information...
1 parent eaea03b commit ee3cc8fd1112598a42d99ae3828ddeeb2809fa58 @guilleiguaran guilleiguaran committed Aug 30, 2011
View
3 actionpack/lib/sprockets/assets.rake
@@ -20,6 +20,7 @@ namespace :assets do
env = Rails.application.assets
target = Pathname.new(File.join(Rails.public_path, config.assets.prefix))
manifest = {}
+ manifest_path = config.assets.manifest || target
if env.respond_to?(:each_logical_path)
config.assets.precompile.each do |path|
@@ -46,7 +47,7 @@ namespace :assets do
env.precompile(*assets)
end
- File.open("#{target}/manifest.yml", 'w') do |f|
+ File.open("#{manifest_path}/manifest.yml", 'w') do |f|
YAML.dump(manifest, f)
end
end
View
8 actionpack/lib/sprockets/railtie.rb
@@ -26,7 +26,13 @@ class Railtie < ::Rails::Railtie
end
end
- if File.exist?(path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml"))
+ if config.assets.manifest
+ path = File.join(config.assets.manifest, "manifest.yml")
+ else
+ path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")
+ end
+
+ if File.exist?(path)
config.assets.digests = YAML.load_file(path)
end
View
1 railties/lib/rails/application/configuration.rb
@@ -43,6 +43,7 @@ def initialize(*)
@assets.debug = false
@assets.compile = true
@assets.digest = false
+ @assets.manifest = "#{root}/public#{@assets.prefix}"
@assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
@assets.js_compressor = nil
@assets.css_compressor = nil
View
3 railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
@@ -20,6 +20,9 @@
# Generate digests for assets URLs
config.assets.digest = true
+ # Defaults to Rails.root.join("public/assets")
+ # config.assets.manifest = YOUR_PATH
+
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
View
17 railties/test/application/assets_test.rb
@@ -79,6 +79,23 @@ def app
assert_match /application-([0-z]+)\.css/, assets["application.css"]
end
+ test "precompile creates a manifest file in a custom path with all the assets listed" do
+ app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
+ app_file "app/assets/javascripts/application.js", "alert();"
+ FileUtils.mkdir "#{app_path}/shared"
+ app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = '#{app_path}/shared'"
+
+ capture(:stdout) do
+ Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
+ end
+
+ manifest = "#{app_path}/shared/manifest.yml"
+
+ assets = YAML.load_file(manifest)
+ assert_match /application-([0-z]+)\.js/, assets["application.js"]
+ assert_match /application-([0-z]+)\.css/, assets["application.css"]
+ end
+
test "assets do not require any assets group gem when manifest file is present" do
app_file "app/assets/javascripts/application.js", "alert();"

0 comments on commit ee3cc8f

Please sign in to comment.