gulp - the streaming build system - Appsterdam Milan

16
gulp The streaming build system Appsterdam Milan 23/10/2014

description

My talk about gulp @ Appsterdam Milan Original HTML slides here: http://bit.ly/appsterdam-gulp Presentation made with Applause: https://github.com/Granze/applause

Transcript of gulp - the streaming build system - Appsterdam Milan

Page 1: gulp - the streaming build system - Appsterdam Milan

gulpThe streaming build system

Appsterdam Milan 23/10/2014

Page 2: gulp - the streaming build system - Appsterdam Milan

whoamiMaurizio Mangione

@granze

Lead FrontendDeveloper

Founder

Page 3: gulp - the streaming build system - Appsterdam Milan

Why gulpcode­over­configuration

speed

easy to read and write

NPM packages

flexibility

Page 4: gulp - the streaming build system - Appsterdam Milan

. . .and Grunt?we owe a big thanks to Grunt, but...

Page 5: gulp - the streaming build system - Appsterdam Milan

Bui ld wars? Who cares!

gulp is coolVS

gulp is cool compared to Grunt

Page 6: gulp - the streaming build system - Appsterdam Milan

Streams

bower search jquery | grep carousel

Streams enable you to pass some data througha number of usually small functions, which willmodify the data and then pass the modifieddata to the next function.“

Page 7: gulp - the streaming build system - Appsterdam Milan

How gulp works

Vinyla metadata object that describes a file

Vinyl adapters (Vinyl­fs)A way to access these files

OrchestratorA module for sequencing and executing tasks anddependencies in maximum concurrency

Page 8: gulp - the streaming build system - Appsterdam Milan

A common task

Credits: Smashing Magazine http://go.shr.lc/SAJ3My

Page 9: gulp - the streaming build system - Appsterdam Milan

A common gulp task var gulp = require('gulp'), jshint = require('gulp-jshint'), uglify = require('gulp-uglify'), concat = require('gulp-concat');

gulp.task('scripts', function () { return gulp.src('js/*.js') .pipe(jshint()) .pipe(uglify()) .pipe(concat('app.js')) .pipe(gulp.dest('build')); });

Page 10: gulp - the streaming build system - Appsterdam Milan

gulp APIs

gulp.task(name[, deps], fn)

gulp.src(globs[, options])

gulp.dest(path[, options])

gulp.watch(glob[, opts, cb])

Page 11: gulp - the streaming build system - Appsterdam Milan

A more "complex" example gulp.task('scripts', function () { return gulp.src('js/*.js') .pipe(jshint()) .pipe(uglify()) .pipe(concat('app.js')) .pipe(gulp.dest('build')); });

gulp.task('styles', function () { return gulp.src('scss/*.scss') .pipe(sass()) .pipe(gulp.dest('css')); });

gulp.task('default', ['scripts', 'styles']);

Page 12: gulp - the streaming build system - Appsterdam Milan

Error handl ing

I’ll be completely honest with you: error management ingulp sucks currently.

­ Eric Schoffstall“

Page 13: gulp - the streaming build system - Appsterdam Milan

Plumber to the rescue! var gulp = require('gulp'), sass = require('gulp-sass'), plumber = require('gulp-plumber');

gulp.task('styles', function () { return gulp.src('scss/*.scss') .pipe(plumber()) .pipe(sass()) .pipe(gulp.dest('css')); });

Page 14: gulp - the streaming build system - Appsterdam Milan

The futuregulp 4

better error handling

task ordering (parallel/series)

better APIs

Page 15: gulp - the streaming build system - Appsterdam Milan

Quest ions?

Page 16: gulp - the streaming build system - Appsterdam Milan

Keep in touch

Twitter ­ Github

@granze

Slides made with Applause