Any ideas on how to use Google Closure Compiler to

2019-02-17 09:22发布

Any ideas on how to use Google Closure Compiler to combine multiple JavaScript files w/o any optimizations? Specifically, we want to use Closure to deploy two versions of our combined site JavaScript: release and debug. For release, we are using --compilation_level SIMPLE_OPTIMIZATIONS --manage_closure_dependencies which is working as intended. However, for debug, we would like our JavaScript to be combined intact/unmodified for easier debugging. It seems the minimum level of optimization is WHITESPACE_ONLY, any ideas would be appreciated.

4条回答
forever°为你锁心
2楼-- · 2019-02-17 09:26

Turns out there's an option to format the processed JavaScript file using the --formatting PRETTY_PRINT. The option indents/formats (with whitespace) the output JavaScript file, such that the JavaScript is easily debuggable.

Wish the documentation is a little more detailed/complete :)

查看更多
欢心
3楼-- · 2019-02-17 09:30

Concatenation works like you'd expect it:

java -jar compiler.jar --js 1.js --js 2.js --js_output_file out.js
查看更多
Lonely孤独者°
4楼-- · 2019-02-17 09:45
--formatting PRETTY_PRINT for beautifying
--debug true for meaningful names (after Advanced compilation)
查看更多
地球回转人心会变
5楼-- · 2019-02-17 09:46

Two thoughts come to mind immediately. First - Why use closure compiler for that task, why not just something like cat jsfile1.js jsfile2.js > debug.js? Second - Closure Inspector will allow you to debug code compiled with Closure Compiler using FireBug.

To help you work with your transformed code, you can also install the Closure Inspector, a tool that makes it easy to use the Firebug JavaScript debugger with the Compiler's output.

查看更多
登录 后发表回答