
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fixβa new CLI tool that turns CVE alerts into safe, automated upgrades.
sprockets_uglifier_with_source_maps
Advanced tools
Create source maps when compressing assets in your Rails applications.
This gem uses Uglifier to create source maps for your concatenated javascripts in Rails. It is meant to be used as a replacement for javascript compressor.
Source maps are useful for debugging javascript and many errors monitoring services utilize them, for example Rollbar.
Rails versions supported: 4.2, 5. For Rails 3.2 see: https://github.com/leifcr/uglifier_with_source_maps
Add this line to your application's Gemfile:
gem 'sprockets_uglifier_with_source_maps'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sprockets_uglifier_with_source_maps
In your Rails applications environment configuration:
config.assets.js_compressor = :uglifier_with_source_maps
If you need to pass options to uglifier:
config.assets.uglifier = {output: {beautify: true, indent_level: 2}, compress: {angular: true}}
Your assets will be built as normal, also maps and concatenated sources will be provided as well in public/assets/maps
and public/assets/sources
.
These subdirs may be configured:
config.assets.sourcemaps_prefix = 'my_maps'
config.assets.uncompressed_prefix = 'my_sources'
Alternatively, sources can be embedded into sourcemaps' sourcesContent
field:
config.assets.sourcemaps_embed_source = true
You can optionally skip gzipping your maps and sources:
config.assets.sourcemaps_gzip = false
By default maps and sources are defined relatively and will be fetched from the same domain your js file is served from. If you are using a CDN you may not want this - instead you might want to use a direct link to your site so you can more easily implement IP or Basic Auth protection:
# set to a url - js will be served from 'http://cdn.host.com' but source map links will use 'http://some.host.com/'
config.assets.sourcemaps_url_root = 'http://some.host.com/'
If you use CloudFront you might want to generate a signed url for these files that limits access based on IP address. You can do that by setting sourcemaps_url_root to a Proc and handling your URL signing there:
# using a Proc - see the AWS SDK docs for everything required to make this work
config.assets.sourcemaps_url_root = Proc.new { |file| MyApp.generate_a_signed_url_for file }
$ rm -rf tmp/cache && rm -rf public/assets && DISABLE_SPRING=true RAILS_ENV=production bin/rake assets:precompile
$ tree public/assets
public/assets
βββ application-f925f01bc55e9831029c1eb2c20ee889.js
βββ maps
βΒ Β βββ application-a3aff92c860f3876615c2d158f724865.js.map
βββ sources
βββ application-73a007cf2d51c423a4420b649344b52e.js
$ tail -n1 public/assets/application-f925f01bc55e9831029c1eb2c20ee889.js
//# sourceMappingURL=/assets/maps/application-a3aff92c860f3876615c2d158f724865.js.map
$ head -c115 public/assets/maps/application-a3aff92c860f3876615c2d158f724865.js.map
{"version":3,"file":"application.js","sources":["/assets/sources/application-73a007cf2d51c423a4420b649344b52e.js"],
If sourcemaps are not generated, try rm -rf tmp/cache
.
git checkout -b my-new-feature
)git commit -m 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that sprockets_uglifier_with_source_maps demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fixβa new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
Weβre excited to announce a powerful new capability in Socket: historical data and enhanced analytics.