Using the --module option in Closure Compiler to create multiple output files

*爱你&永不变心* 提交于 2019-11-28 04:33:01
Chris Moschini
java -jar compiler.jar ^
--module jq:1: --js jquery-1.6.2.js ^
--module t:1:jq: --js test.js ^
--compilation_level ADVANCED_OPTIMIZATIONS

This example will compile out 2 files for you:

  • jq.js
  • t.js

jq.js will be jquery 1.6.2 with advanced minification, and t.js will use that minified version of JQuery properly.

I wish there was a JavaFiddle I could post this to to demonstrate it.


Older version

This original answer was for an older version of Closure Compiler. I've left it intact below in case you're in an environment that needs to keep the older version in place.

How to handle multiple output files, aka modules: http://groups.google.com/group/closure-compiler-discuss/browse_thread/thread/ec7f6809b19b019e/25a94f3994173840

Copy/pasting:

java -jar Build\Tools\compiler.jar ^ 
--compilation_level=ADVANCED_OPTIMIZATIONS ^ 
--externs Build\jQuery.externs.js ^ 
--js Build\Output\Compiling.js ^ 
--js Script/Themes.lang.js ^ 
--js Script/Themes.js ^ 
--module Core:3 ^ 
--js UI/ThemeChooser/ThemeChooser_en.htm.js ^ 
--js UI/ThemeChooser/ThemeChooser.js ^ 
--module UI_ThemeChooser:2:Core ^ 
--js UI/VerticalTabs/VerticalTabs_en.htm.js ^ 
--js UI/VerticalTabs/VerticalTabs.js ^ 
--module UI_VerticalTabs:2:Core ^ 
--js Pager/Pager_en.htm.js ^ 
--js Pager/jquery.Pager.js ^ 
--js Pager/Pager.js ^ 
--module Pager:3:VerticalTabs ^ 
--module_output_path_prefix .\Compiled\ 

And as he notes, --js_output_file is irrelevant when outputting modules.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!