Tips on Rails 4: Assets Compression with Angular.j

If you use Angular.js with Rails, you will know that assets compression will interfere with Angular.js. In Rails 3, the solution is to set compressor in config/environments/production.rb:

config.assets.js_compressor = Sprockets::LazyCompressor.new { Uglifier.new(:mangle => false) }

In Rails 4, Sprockets::LazyCompressor is gone. The solution is simpler, but not obvious:

config.assets.js_compressor = Uglifier.new(:mangle => false)

The reason it works is because in Rails 4, you can have your own compressor as long as it has method :compress, and uglifier does (as an alias of :compile).



article from

Beryllium Work

: http://blog.berylliumwork.com

你可能感兴趣的:(Tips on Rails 4: Assets Compression with Angular.j)