npm.io
0.1.4 • Published 11 years ago

grunt-closure-utilities

Licence
MIT
Version
0.1.4
Deps
2
Vulns
0
Weekly
0

Grunt Closure Utilities

Provide grunt tasks of invoking Google Closure tools.

Getting Started

Install the module:

npm install grunt-closure-utilities --save-dev

Load the tasks with the following line in your grunt.js:

grunt.loadNpmTasks('grunt-closure-utilities');

Sample configurations:

grunt.initConfig({
    /** Generate deps file */
    'closure-deps': {
        fooz: {
            /** Roots with prefixes */
            roots: {
                'tests/fooz': '../../../fooz/'
            },

            /** Output file */
            output: 'tests/output/fooz_deps.js'
        }
    },
    /** Build javascripts */
    'closure-build': {
        common: {
            /** This is an abstraction target, which will do nothing */
            abstract: true,

            /** The entry points */
            entry_points: ['fooz.Foo'],

            /** Files to calculate dependencies for */
            inputs: [],

            /** Paths to scan for dependencies */
            roots: ['tests/fooz', 'tests/closure-library'],

            /** Externs */
            externs: [
                'tests/externs/jquery-1.9.js'
            ],

            /** Defines, key value pairs */
            defines: {
                'fooz.MESSAGE': 'Hi, Google Closure!'
            },

            /**
             * Optimization level
             *  none: WHITESPACE_ONLY
             *  simple: SIMPLE_OPTIMIZATIONS
             *  advanced: ADVANCED_OPTIMIZATIONS
             */
            optimization: 'simple',

            /** Generate exports code for jsdoc @export */
            generate_exports: true,

            /** Create source map file */
            create_source_map: true,

            /** Summary details level, could be 1, 2 or 3 */
            summary_detail_level: 3,

            /** Whether use types information for optimization */
            use_types_for_optimization: true
        },
        unoptimized: {
            /** Inherits configs from target 'options' */
            base: 'common',

            optimization: 'none'/* 'none', 'advanced' */,

            output: 'tests/output/foo.js'
        },
        advanced: {
            /** Inherits configs from target 'options' */
            base: 'common',

            /**
             * Include the deps file to get rid of
             * annoying warnings.
             */
            includes: [
                'tests/closure-library/closure/goog/deps.js'
            ],

            defines: {
                'fooz.MESSAGE': 'Hello, Google Closure!',
                'goog.DEBUG': false
            },

            optimization: 'advanced'/* 'none', 'advanced' */,

            output: 'tests/output/foo-min.js'
        }
    }
});