Top Banner
E
73

Automating Large Applications on Modular and Structured Form with Gulp

Jul 27, 2015

Download

Internet

Anderson Aguiar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Automating Large Applications on Modular and Structured Form with Gulp

E

Page 2: Automating Large Applications on Modular and Structured Form with Gulp

@andersonaguiarFront-end Analyst at

Page 3: Automating Large Applications on Modular and Structured Form with Gulp

why automate?

Page 4: Automating Large Applications on Modular and Structured Form with Gulp

Less mistakes

Delivery faster

Save time

Don’t repeat

Improve quality

Page 5: Automating Large Applications on Modular and Structured Form with Gulp

time isyour

precious

Page 6: Automating Large Applications on Modular and Structured Form with Gulp

WITHOUT AUTOMATE…

Page 7: Automating Large Applications on Modular and Structured Form with Gulp
Page 8: Automating Large Applications on Modular and Structured Form with Gulp
Page 9: Automating Large Applications on Modular and Structured Form with Gulp

automatejust

Page 10: Automating Large Applications on Modular and Structured Form with Gulp

makechoice

http://www.pintjs.com/http://jakejs.com/http://gruntjs.com/http://gulpjs.com/

your

Page 11: Automating Large Applications on Modular and Structured Form with Gulp
Page 12: Automating Large Applications on Modular and Structured Form with Gulp

whouses?

Page 13: Automating Large Applications on Modular and Structured Form with Gulp

https://github.com/gulpjs/gulp/issues/540

Page 14: Automating Large Applications on Modular and Structured Form with Gulp

WHY USE API is simple Easy to start Fast{GULP?

Page 15: Automating Large Applications on Modular and Structured Form with Gulp

API IS SIMPLE

Page 16: Automating Large Applications on Modular and Structured Form with Gulp

API SIMPLE• gulp.task(name, [deps,], fn)

define a task with optional dependencies.

• gulp.src(glob) create a stream from given file system glob.

• gulp.dest(folder) save files from a stream to given directory.

• gulp.watch(glob, tasks) run a task when one of the globed files is changed.

are just four functions

Page 17: Automating Large Applications on Modular and Structured Form with Gulp

gulp.task

Page 18: Automating Large Applications on Modular and Structured Form with Gulp

gulp.task

Page 19: Automating Large Applications on Modular and Structured Form with Gulp

gulp.src

Page 20: Automating Large Applications on Modular and Structured Form with Gulp

gulp.dest

Page 21: Automating Large Applications on Modular and Structured Form with Gulp

gulp.watch

Page 22: Automating Large Applications on Modular and Structured Form with Gulp

————————o read ———o process in memory

——————o write file

Page 23: Automating Large Applications on Modular and Structured Form with Gulp

Now you are a gulp expert!

Page 24: Automating Large Applications on Modular and Structured Form with Gulp

easy to start

Page 25: Automating Large Applications on Modular and Structured Form with Gulp

Download and install node.js: https://nodejs.org/

npm i gulp -g

#1 - INSTALL NODE.JS & GULP

Install gulp globally:

Page 26: Automating Large Applications on Modular and Structured Form with Gulp

• Create a project • Install global Gulp

• Create a package.json

• Install local Gulp

• Create and configure a Gulpfile.js

npm init

[sudo] npm i -g gulp

npm i gulp --save-dev

#2 - CONFIGURE DEV ENVIRONMENT

Page 27: Automating Large Applications on Modular and Structured Form with Gulp

package.json

Page 28: Automating Large Applications on Modular and Structured Form with Gulp

gulpfile.js

Page 29: Automating Large Applications on Modular and Structured Form with Gulp

#3 - INSTALL GULP PLUGINS

http://gulpjs.com/plugins/

Page 30: Automating Large Applications on Modular and Structured Form with Gulp

Install from npm

npm i gulp-uglify --save-dev

Adding to gulp file using require

INSTALLING A PLUGIN

Page 31: Automating Large Applications on Modular and Structured Form with Gulp

USING A PLUGIN

Page 32: Automating Large Applications on Modular and Structured Form with Gulp

That’s it!

Page 33: Automating Large Applications on Modular and Structured Form with Gulp

https://github.com/osscafe/gulp-cheatsheet

Page 34: Automating Large Applications on Modular and Structured Form with Gulp

plugins

Page 35: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/browser-sync

Page 36: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/esformatter

Page 37: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-mocha

Page 38: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-load-plugins

Page 39: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-sass

Page 40: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-less

Page 41: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-stylus

Page 42: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-uglify

Page 43: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-concat

Page 44: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-imagemin

Page 45: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-sourcemaps

Page 46: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-bump

Page 47: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/gulp-zip

Page 48: Automating Large Applications on Modular and Structured Form with Gulp

[ … ]

Page 49: Automating Large Applications on Modular and Structured Form with Gulp

FAST

Page 50: Automating Large Applications on Modular and Structured Form with Gulp

STREAMSare fast

find . | grep -l "coffeescript" | xargs -I {} rm -rf {}

Base on pipe unix

Page 51: Automating Large Applications on Modular and Structured Form with Gulp
Page 52: Automating Large Applications on Modular and Structured Form with Gulp
Page 53: Automating Large Applications on Modular and Structured Form with Gulp
Page 54: Automating Large Applications on Modular and Structured Form with Gulp

https://github.com/substack/stream-handbook

Page 55: Automating Large Applications on Modular and Structured Form with Gulp

https://www.npmjs.com/package/run-sequence

Page 56: Automating Large Applications on Modular and Structured Form with Gulp

GULP 4

Page 57: Automating Large Applications on Modular and Structured Form with Gulp

https://twitter.com/contrahacks/status/560936371012263936

Page 58: Automating Large Applications on Modular and Structured Form with Gulp

gulp.lastRun(task, [timeResolution]) => [Timestamp]

gulp.tree([options]) => Objectgulp.series(taskName || fn...) => Function

gulp.parallel(taskName || fn...) => Function

https://github.com/gulpjs/gulp/labels/gulp4

Page 59: Automating Large Applications on Modular and Structured Form with Gulp

http://blog.reactandbethankful.com/posts/2015/05/01/how-to-install-gulp-4/

Page 60: Automating Large Applications on Modular and Structured Form with Gulp

IMPORTANTdocumentation is very

Page 61: Automating Large Applications on Modular and Structured Form with Gulp
Page 62: Automating Large Applications on Modular and Structured Form with Gulp

workflowimproveyour

Page 63: Automating Large Applications on Modular and Structured Form with Gulp

https://github.com/andersonaguiar/GulpFile

Page 64: Automating Large Applications on Modular and Structured Form with Gulp

ORGANIZE YOUR TASKS BY CONTEXT_default system css js img html

dev

build

deploy

copy

delete

move

rename

exec

preprocessor

source

maps

lints

hint

lint

uglify

formatter

test

optmin

total size

minify

replace

Page 65: Automating Large Applications on Modular and Structured Form with Gulp

gulpfile.js

Page 66: Automating Large Applications on Modular and Structured Form with Gulp

imports.js

Page 67: Automating Large Applications on Modular and Structured Form with Gulp

config.js

Page 68: Automating Large Applications on Modular and Structured Form with Gulp
Page 69: Automating Large Applications on Modular and Structured Form with Gulp

task file

To work with plugins, just install them: npm i gulp-name-plugin --save-dev

Page 70: Automating Large Applications on Modular and Structured Form with Gulp
Page 71: Automating Large Applications on Modular and Structured Form with Gulp

demo code

Page 72: Automating Large Applications on Modular and Structured Form with Gulp

automatemake

just

your lifeeasier

Page 73: Automating Large Applications on Modular and Structured Form with Gulp

@andersonaguiar

QUESTIONS?