JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2100
  • Score
    100M100P100Q127454F
  • License MIT

Gulp plugin for Google Closure Compiler

Package Exports

  • gulp-closure-compiler

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-closure-compiler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gulp-closure-compiler

Build Status Dependency Status devDependency Status

Gulp plugin for Google Closure Compiler

Issues with the output or Java should be reported on the Closure Compiler issue tracker.

Install

npm install --save-dev gulp-closure-compiler

Example

Simple optimizations

Simple optimizations for classic minifying.

var gulp = require('gulp');
var closureCompiler = require('gulp-closure-compiler');

gulp.task('default', function() {
  gulp.src('src/*.js')
    .pipe(closureCompiler({
      compilerPath: 'bower_components/closure-compiler/compiler.jar',
      fileName: 'build.js'
    }))
    .pipe(gulp.dest('dist'));
});

Advanced optimizations

Advanced optimizations is much more aggressive. It's aimed for libraries like Closure Library.

var gulp = require('gulp');
var closureCompiler = require('gulp-closure-compiler');

gulp.task('default', function() {
  gulp.src('src/*.js')
    .pipe(closureCompiler({
      compilerPath: 'bower_components/closure-compiler/compiler.jar',
      fileName: 'build.js',
      compilerFlags: {
        closure_entry_point: 'app.main',
        compilation_level: 'ADVANCED_OPTIMIZATIONS',
        define: [
          "goog.DEBUG=false"
        ],
        externs: [
          'bower_components/este-library/externs/react.js'
        ],
        extra_annotation_name: 'jsx',
        only_closure_dependencies: true,
        output_wrapper: '(function(){%output%})();',
        warning_level: 'VERBOSE'
      }
    }))
    .pipe(gulp.dest('dist'));
});

API

closureCompiler(options)

options

fileName

Type: String
Required

Generated file name.

compilerPath

Type: String
Required

Path to compiler.jar

compilerFlags

Type: Object

Closure compiler flags.

How to download Closure Compiler

Use Bower.

{
  "name": "foo",
  "version": "0.0.0",
  "dependencies": {
    "closure-compiler": "http://dl.google.com/closure-compiler/compiler-latest.zip"
  }
}

Implementation notes

  • Closure compiler supports pipes, but not correctly (issue).
  • You don't need closurebuilder.py script, compiler knows how to resolve dependencies.
  • Java 1.7+ is required.

License

MIT © Daniel Steigerwald