Create sourcemaps when compressing assets in your Rails 3.2 applications.
This gem uses Uglifier to create sourcemaps for your concatenated javascripts in Rails 3.2.x. It is meant to use as a replacement javascript compressor.
Note: This gem is for Rails 3.2.x
For Rails 4.2 see: https://github.com/AlexanderPavlenko/sprockets_uglifier_with_source_maps
Add this line to your application's Gemfile:
gem 'uglifier_with_source_maps'
And then execute:
$ bundle
Or install it yourself as:
$ gem install uglifier_with_source_maps
In your rails applications environment configuration add this:
config.assets.js_compressor = :uglifier_with_source_maps
If you need to pass options to uglifier:
config.assets.js_compressor = UglifierWithSourceMaps::Compressor.new({
output: {
beautify: true, indent_level: 2, comments: :none
}
}) if defined? ::UglifierWithSourceMaps
Your assets will be built as normal, and maps concatenated sources will be provided as well in asset_path/maps and asset_path/sources
Example rake assets:precompile
# application.js
rake assets:precompile
# -> public/assets/application-ab258eecc169e5febb9da42389481bff.js
# -> public/assets/maps/application-ab258eecc169e5febb9da42389481bff.map
# -> public/assets/sources/application-ab258eecc169e5febb9da42389481bff.js
- uglifier >= 2.5
- sprockets ~> 2.2.2
- actionpack ~> 3.2.19
- Fork it ( https://github.com/[my-github-username]/uglifier_with_source_maps/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request