簡體   English   中英

如何使用Google Closure編譯器

[英]How to use Google Closure compiler

我正在嘗試從closurebuilder.py腳本遷移到Closure編譯器,因為這條消息:

../../closure-library/closure/bin/build/closurebuilder.py: Closure Compiler now natively understands and orders Closure dependencies and

優先使用此腳本執行JavaScript編譯

由於我使用的是Google Closure LibraryOpenLayers 3 ,我如何調用編譯器(compiler.jar)來

  • 構建myapp-deps.js依賴文件
  • 構建一個縮小版本myapp.js,其中僅包含已使用的OL3和CL類
  • 使用預先計算的OL3和CL依賴文件(例如ol3-deps.js)構建兩者

讓我們進一步說一切都位於以下結構中。 這幾乎等於我自己的項目,但直接在這里發布是大而復雜的。

project/
    src/
        js/
            <some other js "required" in myapp.js>
            myapp.js
            myapp-deps.js                 # This should be the dependency file
        lib/
            closure/goog/...
            third_party/closure/goog/...  
            myapp.js                      # This should be the minified version
    ol3/

我很感激每一個提示。

Closure Compile現在可以管理Closure依賴項,即在JavaScript代碼中使用goog.providegoog.require定義的依賴項。 所以你不再需要使用closurebuilder.py腳本了。 這就是它被棄用的原因。

請參閱Wiki頁面https://github.com/google/closure-compiler/wiki/Manage-Closure-Dependencies以了解Closure Compiler為此提供的選項/標志。

關於生成deps文件,這可能是為了調試/開發目的逐個加載js文件所必需的,你仍然需要Closure Library的depswriter.py腳本。 Closure Compiler沒有工具或標志。 閱讀https://github.com/google/closure-library/issues/382 depswriter.py已不再在Google中使用,但看起來仍然保留了該腳本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM