Permalink
Browse files

Use uglifier-rails to set default js compressor

  • Loading branch information...
1 parent afd9512 commit 8205081d444a6d1b6a3119a8e611ce3612c8e4df @guilleiguaran committed Jul 29, 2011
View
@@ -19,7 +19,7 @@ end
# This needs to be with require false to avoid
# it being automatically loaded by sprockets
-gem 'uglifier', '>= 1.0.3', :require => false
+gem 'uglifier-rails', '~> 3.2.0.beta', :require => false
gem 'rake', '>= 0.8.7'
gem 'mocha', '>= 0.9.8'
@@ -12,10 +12,8 @@ def run
config.assets.paths.each { |path| app.assets.append_path(path) }
if config.assets.compress
- # temporarily hardcode default JS compressor to uglify. Soon, it will work
- # the same as SCSS, where a default plugin sets the default.
unless config.assets.js_compressor == false
- app.assets.js_compressor = LazyCompressor.new { Sprockets::Compressors.registered_js_compressor(config.assets.js_compressor || :uglifier) }
+ app.assets.js_compressor = LazyCompressor.new { Sprockets::Compressors.registered_js_compressor(config.assets.js_compressor) }
end
unless config.assets.css_compressor == false
@@ -193,21 +193,21 @@ def assets_gemfile_entry
# Gems used only for assets and not required
# in production environments by default.
group :assets do
- gem 'sass-rails', :git => 'https://github.com/rails/sass-rails.git'
- gem 'coffee-rails', :git => 'https://github.com/rails/coffee-rails.git'
+ gem 'sass-rails', :git => 'https://github.com/rails/sass-rails.git'
+ gem 'coffee-rails', :git => 'https://github.com/rails/coffee-rails.git'
#{"gem 'therubyrhino'\n" if defined?(JRUBY_VERSION)}
- gem 'uglifier', '>= 1.0.3'
+ gem 'uglifier-rails', :git => 'https://github.com/guilleiguaran/uglifier-rails.git'
end
GEMFILE
else
<<-GEMFILE
# Gems used only for assets and not required
# in production environments by default.
group :assets do
- gem 'sass-rails', '~> 4.0.0.beta'
- gem 'coffee-rails', '~> 4.0.0.beta'
+ gem 'sass-rails', '~> 4.0.0.beta'
+ gem 'coffee-rails', '~> 4.0.0.beta'
#{"gem 'therubyrhino'\n" if defined?(JRUBY_VERSION)}
- gem 'uglifier', '>= 1.0.3'
+ gem 'uglifier-rails', '~> 3.2.0.beta'
end
GEMFILE
end
@@ -45,6 +45,7 @@ def precompile!
test "assets do not require compressors until it is used" do
app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();"
add_to_env_config "production", "config.assets.compile = true"
+ add_to_env_config "production", "config.assets.js_compressor = :uglifier"
ENV["RAILS_ENV"] = "production"
require "#{app_path}/config/environment"
@@ -58,6 +59,7 @@ def precompile!
test "precompile creates the file, gives it the original asset's content and run in production as default" do
app_file "app/assets/javascripts/application.js", "alert();"
app_file "app/assets/javascripts/foo/application.js", "alert();"
+ add_to_env_config "production", "config.assets.js_compressor = :uglifier"
ENV["RAILS_ENV"] = nil
precompile!

0 comments on commit 8205081

Please sign in to comment.