asset_compress icon indicating copy to clipboard operation
asset_compress copied to clipboard

Source Maps

Open chrisjohnson opened this issue 9 years ago • 9 comments

I can see people have touched on this in the past but I don't see any official requests for this feature. I would love to see it. I am looking at the ClosureJs filter and I can see it would be pretty easy to pass source map variables to the compiler, and I can't imagine it's very hard for the other ones. But I can't do it at the filter level because by then everything has already been aggregated and the original files are lost.

Maybe some sort of way to specify a filter that runs before the aggregation step, or maybe some way for individual filters (like ClosureJs) to disable the aggregation step and perform that themselves? I'm not sure the best way to go about it.

chrisjohnson avatar Feb 23 '15 19:02 chrisjohnson

There is also a pre-preprocess step that has access to each of the input files for a build target. I don't think that gets any closer to having working source map builds though. Source maps create some additional trickiness as the filter system was designed so that build targets would generate a single file, not multiple files. There are other complications around write access to the output directories and development modes that make source maps tricky. I'm not sure I have a simple answer/solution to these problems though.

markstory avatar Feb 24 '15 01:02 markstory

Hi,

I have created the following filter to create source maps using UglifyJS, maybe you can use this?

https://gist.github.com/annuh/679d705ede272448b703

If you'd like I can create a pull request to include this filter?

annuh avatar Jul 07 '15 06:07 annuh

Looks like a good start @annuh. If the source map options were filter config options it could be merged.

markstory avatar Jul 07 '15 10:07 markstory

:+1: I am using Rollbar for production monitoring and it would be nice if there would be be an official way to generate a sourcemap - even with some limitations, even if it would work only with JShrinkFilter and not with UglifyJS or if the source maps would work only if there is no javascript filter. That would be pretty good and useful start too. Thanks alot!

Ref: https://rollbar.com/docs/source-maps/

Laykou avatar Dec 25 '15 11:12 Laykou

I am guessing since this Issue is still open Source Maps are not yet supported?

jonathan-neugber avatar Oct 24 '16 06:10 jonathan-neugber

@jonathan-neugber That is correct.

markstory avatar Oct 24 '16 21:10 markstory

@markstory what do you think about a definition of common configuration parameters for filters which specify sourcemap options, and then each filter can choose to use or not use those configurations (like @annuh's UglifyJs up there) to output a sourcemap? Just trying to think of a way we can at least allow for people to work support in bit by bit, if we can't get global support working easily. The downside to this approach is that unsupported plugins will silently not spit out sourcemaps but at least it's something.

chrisjohnson avatar Oct 24 '16 21:10 chrisjohnson

@chrisjohnson I think enabling source maps through a commonly named option that is implemented where possible is a very reasonable idea.

markstory avatar Oct 25 '16 01:10 markstory

I have seen https://github.com/markstory/asset_compress/issues/230 and this one And I am also a bit annoyed about the warnings in prod env. I wonder if we could also just add a processor that filters out those for prod? Or even dev, if one doesn't want/need them.

dereuromark avatar Nov 24 '20 13:11 dereuromark