Skip to content

Instantly share code, notes, and snippets.

@corinna000
Last active September 8, 2015 20:45
Show Gist options
  • Select an option

  • Save corinna000/831cd15e19df8f8230f6 to your computer and use it in GitHub Desktop.

Select an option

Save corinna000/831cd15e19df8f8230f6 to your computer and use it in GitHub Desktop.

Revisions

  1. corinna000 revised this gist Sep 8, 2015. No changes.
  2. corinna000 created this gist Sep 8, 2015.
    33 changes: 33 additions & 0 deletions Gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    /**
    * Generic Gulpfile for building small AngularJS modules. This does the *very minimum*
    * amount of work to get a module to build.
    * npm install --save-dev gulp gulp-concat gulp-ng-annotate gulp-uglify del
    */
    var gulp = require('gulp');
    var concat = require('gulp-concat');
    var annotate = require('gulp-ng-annotate');
    var uglify = require('gulp-uglify');
    var config = require('./package.json');
    var del = require('del');

    // configure for your source files
    var src = ['./src/**/*.module.js', './src/**/*.js', '!./src/**/*.spec.js'];

    // reads the name of the module distributable from package.json
    var match = config.main.match(/(.*)[/](.*)/);
    var path = match[1];
    var file = match[2];

    gulp.task('clean', function () {
    return del(path);
    });

    gulp.task('build', ['clean'], function () {
    gulp
    .src(src)
    .pipe(concat(file))
    .pipe(annotate())
    .pipe(uglify())
    .pipe(gulp.dest(path));
    });