From 66afabcf4c23db579e7678c28273246d6fe6a505 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 19 Dec 2013 12:33:17 +1100 Subject: [PATCH] stop messing with asset pipeline defaults stripping postfixes is wasteful and uneeded. It messes up our build --- config/environments/test.rb | 3 +++ lib/tasks/assets.rake | 29 ++++++++++------------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 460911dae59..f1db1fda9ea 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 451abba2eb7..67bee04f7df 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' +