How can I get the Rails asset pipeline to produce source maps? How can I get the Rails asset pipeline to produce source maps? javascript javascript

How can I get the Rails asset pipeline to produce source maps?


Rails supports source maps for minified JavaScript! Rails relies on Sprockets for asset compilation, and source maps support was added to Sprockets in this pull request.


If you don't really want source-maps, but instead just want line numbers in coffee-script compile exceptions try this:

It used to be that just having coffee-rails in your Gemfile would produce exceptions with line numbers in the original coffeescript source. Then, they disappeared with a line-number-less exception. I did some digging, and I found that coffee-script-source 1.5.x gave line numbers in the compilation exceptions, while coffee-script-source 1.6.x did not. I believe is a bug, and I wouldn't be surprised if this was "fixed" in the future.

# Gemfilegem 'coffee-rails', '~> 4.0.0'  gem 'coffee-script-source', '~> 1.5.0' # 1.6 doesn't include line numbers in exceptions

Then you'll get exceptions like ('coffee-script-source', '~> 1.5.0')

Showing /Users/.../app/views/layouts/application.html.erb where line #12 raised:SyntaxError: missing } on line 15  (in /Users/.../app/assets/javascripts/app.js.coffee)

Instead of ('coffee-script-source', '~> 1.6.3')

Showing /Users/.../app/views/layouts/application.html.erb where line #12 raised:SyntaxError: missing }  (in /Users/.../app/assets/javascripts/app.js.coffee)