Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate source maps in production? #32

Closed
guillaumebriday-pa opened this issue Jun 29, 2022 · 3 comments
Closed

How to generate source maps in production? #32

guillaumebriday-pa opened this issue Jun 29, 2022 · 3 comments

Comments

@guillaumebriday-pa
Copy link

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

@ahorek
Copy link
Owner

ahorek commented Jun 30, 2022

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.

@ahorek ahorek closed this as completed Jun 30, 2022
@brandoncc
Copy link

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.

@javier-menendez
Copy link
Contributor

javier-menendez commented Mar 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants