简体   繁体   English

是否有任何javascript minifiers保留换行符?

[英]Are there any javascript minifiers that preserve line breaks?

Error reporting from the client that always reports an error on line 1 (because the file is minified) is not very useful. 始终在第1行报告错误的客户端报告错误(因为文件被缩小)不是很有用。 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? 是否有任何javascript minifiers可以选择保留换行符?

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. 如果使用命令行工具,还有很多选项。

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. 我一直在寻找相同的东西,虽然我没有找到我想要的东西,但我刚刚看到(现已弃用) YUI Compressor有一个--line-break 0开关导致换行符每个分号后插入。 Since I was using YUI Compressor anyway, I think this will do for my debugging purposes. 因为无论如何我都在使用YUI Compressor,我认为这样做可以用于我的调试目的。

I think this is it: https://developers.google.com/closure/compiler/docs/inspector 我认为就是这样: 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 :) 正如Fabien所说Closure编译器......但是在第三次查找之后我发现Closure编译器可以在优化代码和原始源之间生成映射文件:)

you also are not limited to use the web service, you can download it as standalone app :) 您也不仅限于使用Web服务,您可以将其作为独立应用程序下载:)

https://developers.google.com/closure/compiler/ https://developers.google.com/closure/compiler/

winwin 双赢的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM