Closure-compiler: --create_source_map should add sourceMappingURL?

Created on 29 Apr 2014  路  12Comments  路  Source: google/closure-compiler

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

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_wrapper argument.

--output_wrapper '(function(){%output%})()\n//# sourceMappingURL=output.js.map'

All 12 comments

:+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.

2088 may be a better solution for you then.

So, if I am understanding correctly, there is no solution for "n" being literally printed to the end of the file?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Muhammad-Salman-Sheikh picture Muhammad-Salman-Sheikh  路  6Comments

joscha picture joscha  路  5Comments

tSte picture tSte  路  5Comments

an3ss picture an3ss  路  4Comments

NekR picture NekR  路  3Comments