Compile JS using the google-closure-service.
This plugin requires Grunt ~0.4.5
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:
npm install grunt-closure-service --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-closure-service');
In your project's Gruntfile, add a section named closure_service
to
the data object passed into grunt.initConfig()
.
grunt.initConfig({
closure_service: {
options: {
// Task-specific options go here. Available options are
// described in the Closure Compiler API Reference.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
For a complete set of options, see the Google Closure Compiler API Reference.
Type: String
Default value: 'SIMPLE_OPTIMIZATIONS'
The compilation level, which can be 'WHITESPACE_ONLY'
,
'SIMPLE_OPTIMIZATIONS'
, or 'ADVANCED_OPTIMIZATIONS'
.
Type: Boolean
Default value: false
Whether to include the Google Closure Library while compiling.
In this example, the default options are used to do compile, which does simple optimizations on the input.
grunt.initConfig({
closure_service: {
options: {},
files: {
'dest/output.min.js': ['src/input1.js', 'src/input2.js'],
},
},
});
In this example, we specify that we only want whitespace removed, with no other optimizations.
grunt.initConfig({
closure_service: {
options: {
compilation_level: 'WHITESPACE_ONLY'
},
files: {
'dest/output.min.js': ['src/input1.js', 'src/input2.js'],
},
},
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.