问题
Error reporting from the client that always reports an error on line 1 (because the file is minified) is not very useful. I'd like to minify my code while preserving line breaks so that I get meaningful line numbers.
Are there any javascript minifiers that have an option to preserve line breaks?
回答1:
Take a look at closure compiler from Google with pretty print option enabled
There are also plenty of options if you use the command line tool.
回答2:
I've been looking for the same thing and although I've not found exactly what I want, I've just seen that the (now deprecated) YUI Compressor has a --line-break 0
switch that causes a line break to be inserted after each semicolon. Since I was using YUI Compressor anyway, I think this will do for my debugging purposes.
回答3:
I think this is it: https://developers.google.com/closure/compiler/docs/inspector
as Fabien said Closure compiler ... but after looking for this for third time I found out that Closure compiler can produce mapping file between optimized code and original source :)
you also are not limited to use the web service, you can download it as standalone app :)
https://developers.google.com/closure/compiler/
winwin
来源:https://stackoverflow.com/questions/10854507/are-there-any-javascript-minifiers-that-preserve-line-breaks