-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Add sourcemap support #490
base: master
Are you sure you want to change the base?
Conversation
What's the status of this PR? Any chance it could be merged in at some point? |
@fdintino This needs tests and docs at least. Are there other compressor supporting source maps that could be added at the same time? |
I've also written support for sourcemaps for uglifyjs and cssclean. I agree on the tests, though I wasn't sure what the best way to go about that is. My first thought was to get node and java packages installed with the .travis.yml and bootstrap the different test cases with package.json files installed into temp directories (there is even an npm package to get closure.jar, so I could even use it for that). I would of course check if |
Thanks for this. I haven't had capacity for working more on my old PR - appreciate you picking this up! |
source_abs_path, staticfiles_storage.base_location) | ||
source_url = staticfiles_storage.url(source_rel_path) | ||
source_map_data['sources'][i] = relurl(source_url, output_url) | ||
source_map = json.dumps(source_map_data, indent="\t") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 2.7's json.dumps doesn't allow strings as arguments for "indent" so I had to change this to indent=4 locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We use python 2.7 so I'm not sure how this initially escaped my notice, but I discovered the same thing and just haven't pushed out the change (I'm still waiting for my unit test branch to get merged in before I rebase this pull request off of it).
Just a thought, do you think it's enough to add source map support at the compression stage but not the compilation stage? Without source maps for compilers, what do you do about coffeescript or ES6/jsx files? |
Provided that the compiler stage adds the 1 Annoyingly, sassc (i.e. libsass), node-sass, and ruby sass all have different command-line flags for enabling source map output |
As you can tell, I've thought a lot about this :-) So the short answer I suppose is that you can add the appropriate flags in your |
This doesn't yet include the unit tests for source maps, but it's freshly rebased off of master (resolving the conflicts) and a few minor fixes are included, in case anyone wants to use this branch while I add tests and documentation. |
@@ -14,9 +14,15 @@ def match_file(self, filename): | |||
|
|||
def compile_file(self, infile, outfile, outdated=False, force=False): | |||
# Pipe to file rather than provide outfile arg due to a bug in lessc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is now obsolete.
Is there any hope of ever merging this? It seems like a lot of the more meaningful, architectural PRs are sort of just being ignored out-of-hand, and I've yet to see any explanation as to why. |
@tobz This PR isn't being ignored, it's on me actually to finish it. I have some work I haven't pushed out yet that allows for sourcemaps for the post-processors that support it, but getting those sourcemaps to concatenate in the compressor step has proved challenging, specifically for javascript. uglifyjs does not support multiple input sourcemaps, nor does closure compiler. One option is to concatenate the sourcemaps in python (the source map spec is not all that complicated) and then pass a single input sourcemap to uglifyjs, but when I attempted that the performance isn't great. I'll work a bit more on it and perhaps leave multilevel sourcemap support for a future pull request. |
@fdintino Adding my two cents on what worked for me: I ended up going with the 'concatenate sourcemaps then feed them to uglifyjs' option, and I used your source-map-concat-cli package to do the compression. Then I wrote a custom compressor to tie it all together. I never cared too much to test the performance since everything is only compiled once for Production anyway, although it seems to run fast enough in development. |
This pull request is based on #346, but somewhat cleaned up (and it looks like that PR might be abandoned).