building workflow in javascript: build the awesome with gulp

18
Gulp An Introduction

Upload: javascript-meetup-hcmc

Post on 15-Jan-2015

499 views

Category:

Technology


0 download

DESCRIPTION

by Vinh Bach, Silicon Straits Saigon

TRANSCRIPT

Page 1: Building workflow in Javascript: Build the awesome with Gulp

GulpAn Introduction

Page 2: Building workflow in Javascript: Build the awesome with Gulp

• Detect errors, running test.

• Concatenating and minifying JS, CSS.

• Compile CoffeeScript, SASS, LESS, etc.

• ….

Page 3: Building workflow in Javascript: Build the awesome with Gulp

“I realized that a task-based build tool with built-in, commonly used tasks was the approach that would work best for me” — Ben Alman (03/2012)

Page 4: Building workflow in Javascript: Build the awesome with Gulp
Page 5: Building workflow in Javascript: Build the awesome with Gulp

A new player appears:

Page 6: Building workflow in Javascript: Build the awesome with Gulp

What is Gulp?• Streaming build system

• Code over configuration

• Small, idiomatic plugins

• Simple API to use

Page 7: Building workflow in Javascript: Build the awesome with Gulp

Streams

Lint Run test

Concatenate Minify

Page 8: Building workflow in Javascript: Build the awesome with Gulp

Streams

Page 9: Building workflow in Javascript: Build the awesome with Gulp

Streams

• Gulp use streams:

• Like the pipe command of *NIX (|)

=> Less I/O operations => Faster building speed

Page 10: Building workflow in Javascript: Build the awesome with Gulp

Config vs Code

Page 11: Building workflow in Javascript: Build the awesome with Gulp

Gulp API

Page 12: Building workflow in Javascript: Build the awesome with Gulp

gulp.src(globs[, options])Returns a readable stream.

Read files that match with provided globs.

Page 13: Building workflow in Javascript: Build the awesome with Gulp

gulp.dest(path)Returns a writable stream.

Write piped file objects to the provided path.

Page 14: Building workflow in Javascript: Build the awesome with Gulp

gulp.task(name[, deps], fn)Register a Gulp task.

Page 15: Building workflow in Javascript: Build the awesome with Gulp

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

Watch files and do something when a file changes.

Page 16: Building workflow in Javascript: Build the awesome with Gulp

Read more…

• GulpJS Homepage

• Gulp by Eric Schoffstall

• Build Wars - Gulp vs Grunt

• Stream Handbook

Page 17: Building workflow in Javascript: Build the awesome with Gulp

Demo

• You can get it from Dropbox:

• http://goo.gl/iFL9JM

Page 18: Building workflow in Javascript: Build the awesome with Gulp

About @Vinh Bachsy• Author: Vinh Bachsy @: [email protected]

• You can follow me at:

• https://plus.google.com/+VinhBachsy

• https://www.facebook.com/vinh.bachsy

• And the Javascript HCM Meetup:

• http://www.meetup.com/JavaScript-Ho-Chi-Minh-City/

• https://www.facebook.com/JavaScriptHCMC

• https://plus.google.com/communities/116105314977285194967