使用google闭包编译器编译javascript的构建方法
c2c.recipe.closurecompile的Python项目详细描述
使用Google Closure Compiler压缩javascript文件
用法
最小构建配置示例:
[buildout] parts = closure-compile [closure-compile] recipe = c2c.recipe.closurecompile compiler = path/to/closure-compiler.jar level = SIMPLE_OPTIMIZATIONS source_map = foo/bar.map externs = externs/a.js externs/b.js input = foo/bar.js output = foo/bar.min.js output_mode = compiled compiler_flags = --generate_exports
其中:
- ^{tt1}$: The location of the compiler jar file.
- ^{tt2}$: The compilation level: ^{tt3}$, ^{tt4}$ or ^{tt5}$. Default is ^{tt3}$.
- ^{tt7}$: Path to the source map file. Optional.
- ^{tt8}$: A list of optional externs files.
- ^{tt9}$: The files to compress separated with spaces. The path can be absolute or relative to the buildout directory. These files are also used to calculate the dependencies in addition to the ^{tt10}$ option.
- ^{tt11}$: The list of paths that should be traversed to build the dependencies.
- ^{tt10}$: One or more namespaces to calculate dependencies for.
- ^{tt13}$: The path to the minified file.
- ^{tt14}$: The type of output to generate from this script. Options are “list” for a list of filenames, “script” for a single script containing the contents of all the files, or “compiled” to produce compiled output with the Closure Compiler. Default is “compiled”.
- ^{tt15}$: A space seperated list of additional compiler flags for the Closure Compiler. They are passed to the compiler as specified. Optional.
深度写入程序
使用DepsWriter写入依赖项文件。
最小构建配置示例:
[buildout] parts = depswriter [closure-compile] recipe = c2c.recipe.closurecompile:depswriter root_with_prefix = myproject ../../myproject ../source/ ../../../../source/ output = path/to/deps.js
其中:
- ^{tt16}$: A list of paths and prefixes.
- ^{tt13}$: The path to the dependency file, can be absolute or relative to the buildout directory.
注意,root和path_with_depspath选项来自 尚不支持原始depswriter.py脚本。
得到罐子
要从google自动下载并解压缩编译器,您可以 使用hexagonit.recipe.download收据:
[buildout] parts = closure-compile [closure-compile] recipe = c2c.recipe.closurecompile compiler = ${download-closure-compile:destination}/compiler.jar ... [download-closure-compile] recipe = hexagonit.recipe.download url = http://closure-compiler.googlecode.com/files/compiler-latest.zip