Miss any of our Open RFC calls?Watch the recordings here! »

grunt-google-closure-tools-compiler

0.1.7 • Public • Published

grunt-google-closure-tools-compiler Flattr this git repo Bountysource

npm version dependencies Build Status Coverage Status
Stories in Ready Built with Grunt

Another Grunt task for Google Closure Compiler. Uses compiler npm build or you can use your own (eg: nightly builds)

(Table of contents generated by [verb])

Getting Started

This plugin requires Grunt >= 0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Install with npm

$ npm install grunt-google-closure-tools-compiler --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-google-closure-tools-compiler');

closurecompiler task

Run this task with the grunt closurecompiler command.

This task requires that you have the closure compiler jar file anywhere on your building machine. However, this plugin loads the npm closure compiler.jar and set it as default compiler. You still can use a custom or another build from closure to set a new path to the jar file you want.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

closure_compilation_level

Choices: 'SIMPLE', 'ADVANCED' , 'WHITESPACE_ONLY'
Default: 'SIMPLE'

Choose which closure compilation level we should use.

closure_create_source_map

Type: Boolean
Default: true

If true, a source map file will be generated in the same directory as the dest file. By default it will have the same basename as the dest file, but with a .map extension.

closure_language_in

Choices: 'ECMASCRIPT3', 'ECMASCRIPT5' , 'ECMASCRIPT5_STRICT', 'ECMASCRIPT6', 'ECMASCRIPT6_STRICT', 'ECMASCRIPT6_TYPED'
Default: 'ECMASCRIPT3' (null)

closure_language_out

Choices: 'ECMASCRIPT3', 'ECMASCRIPT5' , 'ECMASCRIPT5_STRICT', 'ECMASCRIPT6_TYPED'
Default: language in

closure_formatting

Choices: 'PRETTY_PRINT', 'PRINT_INPUT_DELIMITER' , 'SINGLE_QUOTES'
Default: 'PRETTY_PRINT' (null)

debug

Type: Boolean
Default: true

Turn on closure compiler debug parameter.

closure_extra_param

Type: String
Default: null

Set some custom parameters for closure execution.

banner

Type: String
Default: ''

Put a string at the top of the compiled files.

compiler_jar

Type: String
Default: 'node_modules/google-closure-compiler/compiler.jar'

Path to the compiler.jar file. This could be relative beginning from the google-closure-compiler directory or absolute like '/opt/closure-compiler/compiler.jar'.

exec_maxBuffer

Type: Integer
Default: 0

Set maxBuffer if you got message "Error: maxBuffer exceeded."

java_path

Type: String
Default: null

We use this path if it is setted. NOTE: If it is null we can also set the JAVA_HOME environment variable

java_d32

Type: Boolean
Default: false

If this is true, the jar file will be executed with -client and -d32 java parameters.

java_tieredcompilation

Type: Boolean
Default: true

If this is true, the jar file will be executed with -server and -XX:+TieredCompilation java parameters.

Usage Examples

Basic compression

// Project configuration.
grunt.initConfig({
  googleclosurecompiler: {
    my_target: {
      files: {
        'dest/output.min.js': ['src/input1.js', 'src/input2.js']
      }
    }
  }
});

Advanced compilation

// Project configuration.
grunt.initConfig({
  googleclosurecompiler: {
    my_target: {
      options: {
        closure_compilation_level: 'ADVANCED',
        banner: '/*\n' +
                ' * Minified by closure compiler \n' +
                ' */\n'
      },
      files: {
        'dest/output.min.js': ['src/*.js']
      }
    }
  }
});

All files with all subdirectories

// Project configuration.
grunt.initConfig({
  googleclosurecompiler: {
    my_target: {
      options: {
        closure_compilation_level: 'WHITESPACE_ONLY'
      },
      files: {
        'dest/output.min.js': ['src/**']
      }
    }
  }
});

Release History

0.1.7 (2015-12-21)

Bug Fixes
  • task: Add lodash for isUndefined condition instead of grunt.util.kindOf (eccecfb)

0.1.6 (2015-12-20)

Bug Fixes
  • task: Updating closure dependencies (e1cc166)

0.1.5 (2015-12-20)

Bug Fixes
  • package: Move google closure library from dev to normal dependencies (24450ab)
  • task: compile js files and put them into the same directory (f048611)
Features
  • task: Add custom extra parameters config for closure (a89fd1f)
  • task: Add formatting parameter (c8b85c9)
  • task: Add language-in and language-out options (a71416f)

0.1.4 (2015-12-18)

Features
  • task: Show input and output file size after compilation (fe369ae)

0.1.3 (2015-12-18)

Bug Fixes
  • bump: Fixing peerDependencies reference inside readme (da7553e)

0.1.2 (2015-12-18)

Bug Fixes
  • task: Catch error if files object is empty or dest file has an empty array (bd37307)
  • travis-ci: Removing npm uninstall grunt (1959803)
Features
  • task: Add JAVA_HOME and option.java_path to set the java binary path (2c24e70)

0.1.1 (2015-12-17)

0.1.0 (2015-12-17)

ToDo

Some stuff we have to do...

Author

CSoellinger

License

Copyright © 2015 CSoellinger Released under the MIT license.


This file was generated by verb-cli on December 21, 2015.

Install

npm i grunt-google-closure-tools-compiler

DownloadsWeekly Downloads

0

Version

0.1.7

License

MIT

Last publish

Collaborators

  • avatar