class Sprockets::AddSourceMapCommentToAssetProcessor

This is a processor designed to add a source map “comment” to the bottom of a css or JS file that is serving a source map. An example of a comment might look like this

//# application.js-80af0efcc960fc2ac93eda2f7b12e3db40ab360bf6ea269ceed3bea3678326f9.map

As an asset is built it gets source map information added to the ‘asset.to_hash[:map]` key. This contains all the information that is needed to build a source map file.

To add this comment we must have an asset we can link to. To do this we ensure that the original asset is loaded, then we use a use a special mime type. For example ‘application/js-sourcemap+json` for a JS source map.

This will trigger a new asset to be loaded and generated by the ‘SourceMapProcessor` processor.

Finally once we have that file, we can generate a link to it with it’s full fingerprint. This is done and then added to the original asset as a comment at the bottom.