Skip to content

Instantly share code, notes, and snippets.

@awbauer
Last active August 29, 2015 13:57
Show Gist options
  • Save awbauer/9600507 to your computer and use it in GitHub Desktop.
Save awbauer/9600507 to your computer and use it in GitHub Desktop.
Closure build in Sublime3

Closure Compiler as a Sublime3 Build System

  1. Install the Java SDK -- http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
  2. Download the Closure application -- http://dl.google.com/closure-compiler/compiler-latest.zip
  3. Copy the JAR to a convenient location (e.g. ~/compiler.jar)
  4. Create new build system in Sublime -- Tools > Build System > New Build System...
  5. Paste the following into the file: (compiles *.dev.js -> *.js)
    {
    	"shell_cmd": "java -jar ~/compiler.jar --js_output_file ${file_base_name/.dev/''/g}.js ${file_name}",
    	"selector" : "source.js"
    }
    
  6. Save the file.
  7. Enjoy quick builds!

Alternate configs

  • Compile *.js -> *.min.js

     {
     	"shell_cmd": "java -jar ~/compiler.jar --js_output_file ${file_base_name}.min.js ${file_name}",
     	"selector" : "source.js"
     }
    
  • Output compiled code to console (only)

     {
     	"shell_cmd": "java -jar ~/compiler.jar ${file_name}",
     	"selector" : "source.js"
     }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment