Feature Request: SourceMap Header for public and/or assets plugin?

13 views
Skip to first unread message

fnor...@gmail.com

unread,
Feb 7, 2025, 10:57:27 AMFeb 7
to Roda
Hi all,
Hi Jeremy Evans,

I find source map handling, injecting the correct magic comment into minified files, a bin of a pita and stumbled upon the SourceMap HTTP header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap

So I thought, maybe it would be nice if the public plugin (and/or assets - I'm currently only using the former) could inject that header automatically if a matching "*.map" file exists, using all the correct prefix paths.

I've tried to "Module prepend" this without much success, b/c the public plugin is too tightly packed to inject headers dynamically.
Maybe, as a more general approach, a dynamic headers callback that receives the original requested path and the resolved path (eg. compressed file) would be possible?

Thanks for hearing me out.
All the best and as always thanks for all the work!

- Robert

Jeremy Evans

unread,
Feb 7, 2025, 11:06:00 AMFeb 7
to ruby...@googlegroups.com
On Fri, Feb 7, 2025 at 7:57 AM fnor...@gmail.com <fnor...@gmail.com> wrote:
Hi all,
Hi Jeremy Evans,

I find source map handling, injecting the correct magic comment into minified files, a bin of a pita and stumbled upon the SourceMap HTTP header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap

So I thought, maybe it would be nice if the public plugin (and/or assets - I'm currently only using the former) could inject that header automatically if a matching "*.map" file exists, using all the correct prefix paths.

I don't want to add dynamic headers to the public plugin.  It would only make sense to do this for the assets plugin if the assets plugin can build a source map.  I never added support for building source maps to the assets plugin, due to the complexity, and because sass can build an embedded source map just by passing the correct :css_options, so on my applications, the development environment would build with an embedded source map, and the production version wouldn't use a source map.

I've tried to "Module prepend" this without much success, b/c the public plugin is too tightly packed to inject headers dynamically.
Maybe, as a more general approach, a dynamic headers callback that receives the original requested path and the resolved path (eg. compressed file) would be possible?

You could use the multi_public plugin, have the stylesheets served out of separate r.multi_public call, and have that use the SourceMap header.  Alternatively, you could just have a regular route for the stylesheet, and set the header and return the stylesheet.

Thanks,
Jeremy
Reply all
Reply to author
Forward
0 new messages