How to generate source maps in production?
guillaumebriday-pa opened this issue · comments
Hey
I use Sprockets 4.1 in production and I would like to generate source maps in production with Terser.
Is it possible? How to do it?
Thanks in advance
terser-ruby itself does support source maps https://github.com/ahorek/terser-ruby/blob/master/lib/terser/compressor.rb#L36 so there's nothing to be done here
sprockets does generate dynamic sourcemaps only in development mode, static sourcemaps aren't supported, see rails/sprockets#502
you can still link your own sourcemaps like this
//= link application.js.map
//# sourceMappingURL=application.js-d54377f4bfe13c83f772d0a7c353127a0d7388afe67fcca1344b5cdac0370c1c.map
but you have to generate them manually / write your own generator, which may not be trivial for libraries that consist of many files.
it's also very unlikely that sprockets will introduce the feature, because the development is pretty dead, if you need sourcemaps, consider switching to a different asset management tool.
I have been using this for a long time, and now I'm having an issue compiling with uglifier for some reason. I'm considering switching to terser and migrating that code to work with terser instead of uglifier.
I have been using this for a long time, and now I'm having an issue compiling with uglifier for some reason. I'm considering switching to terser and migrating that code to work with terser instead of uglifier.
I made a fork to use terser instead of uglifier, in case it is still needed for some apps sprockets_terser_with_source_maps