mirror of https://github.com/rails/rails
Merge pull request #3136 from guilleiguaran/clear-digests-on-precompile
Avoid use of existing precompiled assets during rake assets:precompile run
This commit is contained in:
parent
17882d2a9e
commit
cf90181d84
|
@ -25,6 +25,10 @@ namespace :assets do
|
|||
|
||||
env = Rails.application.assets
|
||||
|
||||
# Always compile files and avoid use of existing precompiled assets
|
||||
config.assets.compile = true
|
||||
config.assets.digests = {}
|
||||
|
||||
target = File.join(Rails.public_path, config.assets.prefix)
|
||||
static_compiler = Sprockets::StaticCompiler.new(env, target, :digest => config.assets.digest)
|
||||
|
||||
|
|
|
@ -256,6 +256,24 @@ module ApplicationTests
|
|||
assert_match(/\/assets\/rails-([0-z]+)\.png/, File.read(file))
|
||||
end
|
||||
|
||||
test "precompile shouldn't use the digests present in manifest.yml" do
|
||||
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
|
||||
|
||||
ENV["RAILS_ENV"] = "production"
|
||||
precompile!
|
||||
|
||||
manifest = "#{app_path}/public/assets/manifest.yml"
|
||||
assets = YAML.load_file(manifest)
|
||||
asset_path = assets["application.css"]
|
||||
|
||||
app_file "app/assets/images/rails.png", "image changed"
|
||||
|
||||
precompile!
|
||||
assets = YAML.load_file(manifest)
|
||||
|
||||
assert_not_equal asset_path, assets["application.css"]
|
||||
end
|
||||
|
||||
test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do
|
||||
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
|
||||
add_to_config "config.assets.compile = true"
|
||||
|
|
Loading…
Reference in New Issue