PG6300-14-04 Toolchain & modular API

Introducing Gulp

Blubb blubb

gulpfile.js

var gulp = require('gulp');

gulp.task('hello', function() {
    console.log('Hello, world!');
});

__

$ gulp hello
[11:56:09] Using gulpfile ~/gulpfile.js
[11:56:09] Starting 'hello'...
Hello, world!
[11:56:09] Finished 'hello' after 120 μs
$ 

/assets/app.js

var gulp = require('gulp');
var concat = require('gulp-concat');

gulp.task('js', function() {
    gulp.src('client/**/*.js')
        .pipe(concat('app.js')
        .pipe(gulp.dest('assets'))
});

?

module.js

angular.module('app', [
]);

Files with gulp

/
`- gulpfile.js
`- client
 `- index.html
 `- module.js
 `- controllers
  `- posts.controller.js
 `- services
  `- posts.service.js

ng-annotate

Uglify!

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

gulp.task('js', function() {
    gulp.src(['client/module.js', 'client/**/*.js'])
        .pipe(concat('app.js')
        .pipe(ngAnnotate())
        .pipe(uglify())
        .pipe(gulp.dest('assets'))
});

PG6300-14-04 Toolchain & modular API

By theneva

PG6300-14-04 Toolchain & modular API

  • 529