Depth table of contents of one of the most popular screencast about utility for managing tasks.
What is Gulp? Compare with Webpack.
What is Gulp?
- Gulp as a “streaming build system”, and moreover, it’s a utility for declaring tasks 0:10
- Example
gruntfile.js
0:53 - Comparing with Grunt. 2:50
gruntfile.js
vsgruntfile.js
- More compact config
- Virtual File System - Vinyl FS. No temp folders
- Power of streams, streams parallelism
- Comparing with Webpack 10:10
- Deps: CommonJS, AMD, ES2015
- Dynamic loading
- CommonsChungPlugin
- APIs
- Webpack + Gulp = 💕 16:45
- Tasks: Gulp
- JS Build: Webpack
Install and task running
- Installing strategies: local vs global 0:22
- Installing v4
npm i -D gulpjs/gulp.git#4.0
- First task 3:49
- Callback for finish async operation
- Task name as function name
- Separate tasks with namespace
deploy:production
- Strategies for finish async operations
gulp.series
andgulp.parallel
Streams Vinyl-FS
- Example streams with coping files 0:45
gulp.src
andgulp.dest
output as readable/writable streams of instance Vinyl-FS 1:05- Log working files
.on('data', (file) => file)
1:48 - File getter properties 3:10
- Control
gulp.dest
output 4:45 - Module
minimatch
and popular pattens 6:48 - Performance issue with globs 9:13
- Summary 11:50
Basic build for styles
- App structure 0:25
- Declaring task for stylus 1:13
- Change destination directory 5.40
- Concat files 7:10
- Log info with
gulp-debug
7:50 - Create
main.styl
10:31 - Add source maps 11:30
- Generate source maps only in dev mode 15:05
- Using
gulp-if
17:05 - Create
clean
task withdel
19:05 - Create
copy
task withgulp.parallel
20:24 - Result in browser with
node-static
21:55 - Summary 23:18
Incremental build, watch
- Create
gulp.watch
for styles 0:30 - What does “incremental build” actually mean? Caching 1:55
- Create
gulp.watch
for assets with caching with{ since: gulp.lastRun('taskName') }
3:55 - Module
chokidar
and deleting files with watch 6:49 - Decoupling watch-es into separate task 8:32
- Summary 9:32
Incremental and performance
- Filter new files for first task run with
gulp-newer
0:36 - Problem with
gulp-remember
on example withgulp-autoprefixer
3:57 - Problem with returning deleted files from IDE, using
gulp-cached
as alternative ofsince
10:10 - Summary 15:20
Browser auto-reloading, browser-sync
Error handling
- Make an error 0:20
- Was error couched? 1:25
- Notification for an error with
gulp-notify
2:51 - Catch all errors on task with
gulp-plumber
6:30 - Solution with
multipipe
9:50
Creating plugins with “through2”
More complex stream with “eslint”, “gulp-if”, “stream-combiner2”
How we know Node.JS streams?
Structure of “gulpfile.js”
- We have problems, don’t we? 0:20
- A solution is task decomposition 1:50
- Adding
gulp-load-plugins
5:05 - Result after refactoring 6:50
A real example: styles, assets, sprites, production
- Goal and app structure 0:15
- Improving build of styles and assets 1:55
- A typical problem with preprocessors with
src
and fixing withresolver
4:03 - Working with sprites using
gulp-svg-sprites
6:20 - Add production mode: minify with
gulp-cssnano
, resource hash withgulp-rev
andgulp-rev-replace
15:13 - Do we need to use long-term hashing for images? 22:17
- Summary 25:35
Integration with Webpack
- Summary 27:16