Uglifier does not work on rails

config/application.rb ... # Enable the asset pipeline config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' config.assets.digest = true config.assets.paths << "#{Rails.root}/vendor/assets/images" ... config/environment.rb ... ENV['RAILS_ENV'] ||= 'production' ... My gemfile ... gem 'uglifier' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" #gem 'uglifier' end ... environment/production.rb .... config.active_support.deprecation = :notify config.assets.enabled = true config.assets.js_compressor = :uglifier config.assets.css_compressor = :scss config.assets.compress = false ... 

I have javascript files in app / assets / javascripts. My javascript files are not compressed. Following this url is http://dev.mensfeld.pl/category/rails3/ for compressing your workout.

Thanks for any guidance.

+7
source share
3 answers

In the environment /production.rb:

 ... config.assets.compress = true ... 
+10
source

I had the same problem, and after a big hair break it was discovered that you had to modify the asset file to cause compression.

The compression seems to depend on the mtime file file, which makes sense, since one of the problems that pursues the goal is this: ( Rails guide ):

... when static assets are deployed with each new version of the code, the mtime of all these files changes, causing all remote clients to retrieve them again, even if the contents of these assets have not changed.

+8
source

use this command:

 rake RAILS_ENV=production RAILS_GROUP=assets assets:precompile 
+2
source

All Articles