Disable source maps support in Sprockets 4


Env: Rails 6, Sprockets 4

I spent quite a decent amount of time trying different config options without success. Sprockets keep dynamically adding

//# sourceMappingURL=application.js-a5970c2deb76a38d2c69d9af9da83dc5d4aeaf1d68444918b225e824475d8737.map

to the end of application.js in dev env.

I have inlined source maps at the end of this file already. I generate application.js using Webpack directly with its support for source maps. So I would like to skip this redundant addition by Sprockets. Is this even possible? How to disable source maps support for Sprockets?

I haven’t tested this but you can delete Preprocessors:

You should probably be able to delete the Preprocessors::DefaultSourceMap.

Maybe something like:

env.unregister_processor('application/javascript', Preprocessors::DefaultSourceMap)