diff --git a/config/environments/test.rb b/config/environments/test.rb index 460911dae..f1db1fda9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -37,6 +37,9 @@ Discourse::Application.configure do config.pbkdf2_iterations = 10 config.ember.variant = :development + config.assets.compile = true + config.assets.digest = false + # silence deprecation warnings in test config.whiny_nils = true unless rails4? config.eager_load = false if rails4? diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 451abba2e..67bee04f7 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -1,23 +1,14 @@ -task 'assets:precompile' => 'environment' do - # see: https://github.com/rails/sprockets-rails/issues/49 - # a decision was made no longer to copy non-digested assets - # this breaks stuff like the emoji plugin. We could fix it, - # but its a major pain with little benefit. - if rails4? - puts "> Copying non-digested versions of assets" - assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*')) - regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/ - assets.each do |file| - next if File.directory?(file) || file !~ regex - next if File.extname(file) == ".json" # Avoid duplicate manifest - source = file.split('/') - source.push(source.pop.gsub(regex, '.')) +task 'assets:precompile:before' do - non_digested = File.join(source) - FileUtils.cp(file, non_digested) - end - puts "> Removing cache" - `rm -fr tmp/cache` + unless %w{profile production}.include? Rails.env + raise "rake assets:precompile should only be run in RAILS_ENV=production, you are risking unminified assets" end + + # in the past we applied a patch that removed asset postfixes, but it is terrible practice + # leaving very complicated build issues + # https://github.com/rails/sprockets-rails/issues/49 end + +task 'assets:precompile' => 'assets:precompile:before' +