This issue was imported from Closure Compiler's previous home at http://closure-compiler.googlecode.com
The original discussion is archived at:
http://blickly.github.io/closure-compiler-issues/#941
:+1:
There are is already a much more flexible method for doing this. You can add the source mapping URL (and much more) with the output_wrapper argument.
--output_wrapper '(function(){%output%})()\n//# sourceMappingURL=output.js.map'
Chad, do you want to add this to the FAQ?
@concavelenz Done. https://github.com/google/closure-compiler/wiki/FAQ#source-maps-and-sourcemappingurl
@ChadKillingsworth I'm not seeing this work. I'm able to generate the map, but it doesn't add the sourceMappingUrl to the minified js file.
@tburdeinei this is working as intended. The Faq linked above has the exact answer.
n in the --output_wrapper command doesn't seem to add a new line as expected, it seems to be escaped and "n" is literally printed to the end of the file. On top of that, I can't use %output% in a .bat file It gives a ERROR - invalid output_wrapper specified. Missing '%output%'.
Windows command line escaping is tricky. And it's different still if you installed some of the shell integration that comes with Git for Windows. I've not come across the escaping \n before though. You might try using a flagfile - that should bypass the shell escaping issues.
In a .bat file, you need 2 % characters otherwise it is assumed to be an environment variable reference: %%output%%.
Thanks for the quick response. The double %% works well. A little bit more googling and my own tests shows that n is being sent into java as literals and is not reinterpreted as a line break command... at least in windows. Perhaps a shell integration would silently fix that issue, but it does not work on bog standard windows CMD. That said, not being on a new line does not seem to affect the //# sourceMappingURL detection on browsers, at least in Chrome.
It will be nice to have the %outname% variable to change the name of the file. I'm using a plugin to minify, and I'm not able to set the correct name to the files.
It will be nice to use it like:
%output%//# sourceMappingURL=%outname%.map.
So, if I am understanding correctly, there is no solution for "n" being literally printed to the end of the file?
Most helpful comment
There are is already a much more flexible method for doing this. You can add the source mapping URL (and much more) with the
output_wrapperargument.