/angular-annotate-asset-pipeline

AngularJs Annotation module for the Asset Pipeline

Primary LanguageBatchfile

AngularJs Annotate Asset-Pipeline

The angular-annotate-asset-pipeline is an Asset Pipeline module that provides annotations for dependecy injection to allow angular JavaScript or CofeeScript files to be minified in Gradle and Grails projects.

Getting started

Gradle / Grails 3

build.gradle
plugins {
    id 'com.bertramlabs.asset-pipeline' version '2.5.0'
}

dependencies {
    assets 'com.craigburke.angular:angular-annotate-asset-pipeline:2.4.1'
}

Grails 2

Add the plugin to your BuildConfig.groovy:

BuildConfig.groovy
plugins {
    runtime ":angular-annotate-asset-pipeline:2.4.1"
}

How it works

Since the parameter names are significant for AngularJS to do dependency injection and most minifiers rename parameters, you have to use inline annotations. See A Note on Minification

This plugin uses ng-annotate v1.2.1 to add those inline annotations and make your angular files safe to minify.

For example this

function IndexController($scope) {
    $scope.message = "Hello world";
};

Will be automatically annotated like so:

function IndexController($scope) {
    $scope.message = "Hello world";
};
IndexController.$inject = ["$scope"];

Contributions

Thank you to the following people who have made major contributions to this module in terms of both feedback and code: