[英]Google Closure external dependencies
I want to load one single, minified javascript file per page instead of dozens. 我想每页加载一个缩小的javascript文件,而不是几十个。 I'd like to use Closure Compiler to create these so called modules.
我想使用Closure Compiler创建这些所谓的模块。 But I have dependencies like jQuery or Codemirror for example.
但是我有像jQuery或Codemirror这样的依赖项。
Can I make the Compiler automatically include these for all output, without having to wrap these libraries into Closure specific code to provide a namespace recognized by Closure? 是否可以使编译器自动为所有输出包括这些内容,而不必将这些库包装到Closure特定代码中以提供Closure可以识别的名称空间?
Yes - if you use the SIMPLE_OPTIMIZATIONS
level of the compiler you can feed all your dependencies into the compiler and it will output a single JS file. 是的-如果您使用编译器的
SIMPLE_OPTIMIZATIONS
级别,则可以将所有依赖项输入到编译器中,它将输出一个JS文件。 SIMPLE_OPTIMIZATIONS
will work correctly with most code libraries. SIMPLE_OPTIMIZATIONS
将在大多数代码库中正常工作。
java -jar compiler.jar -O SIMPLE --js jquery.s --js otherlib.js --js myfile.js
--js_output_file mycombinedfile.js
However, Closure-compiler will need some method of determining the source files if you don't want to list them manually. 但是,如果您不想手动列出源文件,则Closure-compiler将需要一些确定源文件的方法。 The compiler can be used with the closure-library dependency management or with Common JS dependency management.
编译器可与闭包库依赖管理或Common JS依赖管理一起使用。
If you don't want to use either of those, you would need a method (like a script) to determine all of the applicable source files and feed those to the compiler in the correct order .
如果您不想使用其中任何一个,则需要一个方法(如脚本)来确定所有适用的源文件,并以正确的顺序将它们提供给编译器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.