Use https://github.com/btford/ngmin in the Rails asset pipeline.
Add this line to your application's Gemfile:
gem 'ngmin-rails'
And then execute:
$ bundle
That's it! ngmin-rails integrates seamlessly into the Rails asset pipeline; your JavaScript or CoffeeScript assets will automatically be run through the ngmin pre-minifier.
The ngmin-rails version number mirrors the version number for the version of ngmin that is bundled with it.
-
Q: I installed ngmin-rails, but my assets aren't getting processed with ngmin.
A: Remember to delete
tmp/cache/assets
ortouch
all the related asset files so that the cached versions get regenerated. If you've precompiled your assets intopublic/assets
, you'll need to re-precompile them.
The actual ngmin project is bundled into this gem via Browserify. You can update to the latest version of ngmin via Rake:
rake ngmin:build
There is a Rails 3 application bundled in example/
that you can use to test the asset pipeline integration. Don't forget to remove tmp/cache/assets
after upgrading to the latest version of ngmin.