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.js0:53 - Comparing with Grunt. 2:50
gruntfile.jsvsgruntfile.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.seriesandgulp.parallel
Streams Vinyl-FS
- Example streams with coping files 0:45
gulp.srcandgulp.destoutput 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.destoutput 4:45 - Module
minimatchand 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-debug7:50 - Create
main.styl10:31 - Add source maps 11:30
- Generate source maps only in dev mode 15:05
- Using
gulp-if17:05 - Create
cleantask withdel19:05 - Create
copytask withgulp.parallel20:24 - Result in browser with
node-static21:55 - Summary 23:18
Incremental build, watch
- Create
gulp.watchfor styles 0:30 - What does “incremental build” actually mean? Caching 1:55
- Create
gulp.watchfor assets with caching with{ since: gulp.lastRun('taskName') }3:55 - Module
chokidarand 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-newer0:36 - Problem with
gulp-rememberon example withgulp-autoprefixer3:57 - Problem with returning deleted files from IDE, using
gulp-cachedas alternative ofsince10: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-notify2:51 - Catch all errors on task with
gulp-plumber6:30 - Solution with
multipipe9: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-plugins5: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
srcand fixing withresolver4:03 - Working with sprites using
gulp-svg-sprites6:20 - Add production mode: minify with
gulp-cssnano, resource hash withgulp-revandgulp-rev-replace15:13 - Do we need to use long-term hashing for images? 22:17
- Summary 25:35
Integration with Webpack
- Summary 27:16