Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'd like to have Rails produce source maps alongside the compiled coffeescript/minified JS, for better error logging. There doesn't seem to be comprehensive documentation on the net on how to do this, yet, though. Has anyone done this?

I'm on Rails 3.2 and Heroku.

like image 247
Vincent Woo Avatar asked Jan 30 '13 00:01

Vincent Woo


People also ask

How does Rails asset pipeline work?

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

What does Rails assets Precompile do?

The Rails asset pipeline provides an assets:precompile rake task to allow assets to be compiled and cached up front rather than compiled every time the app boots. There are two ways you can use the asset pipeline on Heroku. Compiling assets locally.

What is source map in browser?

A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.

What is JavaScript source map?

A Sourcemap is a file that maps from the transformed source to the original source. It is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of Sourcemaps is to aid debugging.


1 Answers

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.

like image 56
jsanders Avatar answered Sep 22 '22 05:09

jsanders