mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #2780 from guilleiguaran/assets-pipeline-minor-changes
Assets pipeline: fix in manifest location and remove unused code
This commit is contained in:
parent
c5a91d0288
commit
3ce3b5b1f1
3 changed files with 27 additions and 21 deletions
|
@ -23,29 +23,22 @@ namespace :assets do
|
||||||
manifest = {}
|
manifest = {}
|
||||||
manifest_path = config.assets.manifest || target
|
manifest_path = config.assets.manifest || target
|
||||||
|
|
||||||
if env.respond_to?(:each_logical_path)
|
config.assets.precompile.each do |path|
|
||||||
config.assets.precompile.each do |path|
|
env.each_logical_path do |logical_path|
|
||||||
env.each_logical_path do |logical_path|
|
if path.is_a?(Regexp)
|
||||||
if path.is_a?(Regexp)
|
next unless path.match(logical_path)
|
||||||
next unless path.match(logical_path)
|
else
|
||||||
else
|
next unless File.fnmatch(path.to_s, logical_path)
|
||||||
next unless File.fnmatch(path.to_s, logical_path)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if asset = env.find_asset(logical_path)
|
if asset = env.find_asset(logical_path)
|
||||||
manifest[logical_path] = asset.digest_path
|
manifest[logical_path] = asset.digest_path
|
||||||
filename = target.join(asset.digest_path)
|
filename = target.join(asset.digest_path)
|
||||||
mkdir_p filename.dirname
|
mkdir_p filename.dirname
|
||||||
asset.write_to(filename)
|
asset.write_to(filename)
|
||||||
asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
|
asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
|
||||||
end
|
|
||||||
end
|
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
|
||||||
|
|
||||||
File.open("#{manifest_path}/manifest.yml", 'w') do |f|
|
File.open("#{manifest_path}/manifest.yml", 'w') do |f|
|
||||||
|
|
|
@ -43,7 +43,7 @@ module Rails
|
||||||
@assets.debug = false
|
@assets.debug = false
|
||||||
@assets.compile = true
|
@assets.compile = true
|
||||||
@assets.digest = false
|
@assets.digest = false
|
||||||
@assets.manifest = "#{root}/public#{@assets.prefix}"
|
@assets.manifest = nil
|
||||||
@assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
|
@assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
|
||||||
@assets.js_compressor = nil
|
@assets.js_compressor = nil
|
||||||
@assets.css_compressor = nil
|
@assets.css_compressor = nil
|
||||||
|
|
|
@ -96,6 +96,19 @@ module ApplicationTests
|
||||||
assert_match /application-([0-z]+)\.css/, assets["application.css"]
|
assert_match /application-([0-z]+)\.css/, assets["application.css"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "the manifest file should be saved by default in the same assets folder" do
|
||||||
|
app_file "app/assets/javascripts/application.js", "alert();"
|
||||||
|
app_file "config/initializers/manifest.rb", "Rails.application.config.assets.prefix = '/x'"
|
||||||
|
|
||||||
|
capture(:stdout) do
|
||||||
|
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
|
||||||
|
end
|
||||||
|
|
||||||
|
manifest = "#{app_path}/public/x/manifest.yml"
|
||||||
|
assets = YAML.load_file(manifest)
|
||||||
|
assert_match /application-([0-z]+)\.js/, assets["application.js"]
|
||||||
|
end
|
||||||
|
|
||||||
test "assets do not require any assets group gem when manifest file is present" do
|
test "assets do not require any assets group gem when manifest file is present" do
|
||||||
app_file "app/assets/javascripts/application.js", "alert();"
|
app_file "app/assets/javascripts/application.js", "alert();"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue