/grunt-ng-boba

Grunt plugin for ngBoba: Angular Dependency Manager

Primary LanguageJavaScriptMIT LicenseMIT

grunt-ng-boba

Grunt task for ngBoba: Angular Dependency Manager

Getting Started

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-ng-boba --save-dev

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

grunt.loadNpmTasks('grunt-ng-boba');

The "ngBoba" task

Overview

In your project's Gruntfile, add a section named ngBoba to the data object passed into grunt.initConfig().

Check out our seed project ng-boba-seed to see an example of how to use ngBoba with grunt.

grunt.initConfig({
    ngBoba: {
        options: {
            modules: ["myModule"],
            moduleFormat: "anonymous",
            dependencies: [
                "src/someDependency.js"
            ]
        },
        build: {
            src: 'src/project/**/*.js',
            dest: 'build/project.min.js'
        }
    }
});

Options

options.modules

Type: String[] Default value: []

The module's dependencies that you want to bundle.

options.moduleFormat

Type: String Default value: 'anonymous'

The format used to define your module dependencies, 'anonymous' or 'array' depending on if anonymous functions or array notation is used.

options.dependencies

Type: String[] Default value: []

Scripts that cannot be detected by Angular's dependency injection, but are required for the project. An example of this would be jQuery.

options.shims

Type: {}

Allows dependencies to specified manually

options.ignoreModules

Type: String[]

Modules that will not be included in the bundle.

Usage Examples

grunt.initConfig({
    ngBoba: {
        options: {
            modules: ["myModule"],
            moduleFormat: "anonymous",
            dependencies: [
                "src/someDependency.js"
            ],
            ignoreModules: [
                "mModule"
            ],
            shims: {
                "file/path.js": [
                  "moduleName",
                  "moduleName.ControllerName",
                  "moduleName.directiveName"
                ],
                "other/file.js": [
                  "moduleName.directiveName2"
                ]
            },
        },
        build: {
            src: 'src/project/**/*.js',
            options: {
                modules: ['moduleName']
                output: 'path/to/outputFile.json'
            }
        }
    }
});