angularjsgulpgulp-ng-annotate

gulp-ng-annotate - how to use it?


I want to minify my big angular project.

Using angular 1.5.0.

I'm trying to use the module gulp-ng-annotate to do so.

var gulp = require('gulp');
var ngAnnotate = require('gulp-ng-annotate');

gulp.task('default', function () {
return gulp.src('../www-myalcoholist-com-angular/model/app.js')
    .pipe(ngAnnotate())
    .pipe(gulp.dest('dist'));
});

when I execute this nodejs script, it fails silently. or... welll.. it doesn't do anything.

i gave it only the main app.js file as a parameter. can I some how give it the all project ?

when I run ng-annotate from terminal, it added annotations properly to my project.. well.. i hope :)

so why this script fails?

I'm new to gulp so any information would be greatly appreciated.


Solution

  • gulp-ng-annotate does not try to find other files in your application. You'll need to either concat your application into a single app.js file before piping to gulp-ng-annotate or src all files separately and pass them to`gulp-ng-annotate.

    E.g. the concat method:

    var gulp = require('gulp');
    var ngAnnotate = require('gulp-ng-annotate');
    var concat = require('gulp-concat');
    
    gulp.task('default', function () {
     return gulp.src('../www-myalcoholist-com-angular/model/**/*.js')
        .pipe(concat('app.js'))
        .pipe(ngAnnotate())
        .pipe(gulp.dest('dist'));
    });