Slides from my presentation at ViennaJS meetup on 24 June 2015 on Streams in Gulp.js
You can also read an article based on this talk I have written: https://florian.ec/articles/gulp-js-streams/
Streams in Gulp.jsFLORIAN ECKERSTORFERhttps://florian.ec
View Slide
Build System
Task Runner
GNU MakeAntPhingRakeGrunt
Gulp is different
Code instead of ConfigurationNode.js Streams
Node.js Streams
CoffeeScript FilesCompile to JavaScriptConcatenateMinifyCopy to dist/ directory
Traditional TaskRunner
Read src/*.coffee ➞ Compile ➞ Save tmp/*.jsRead tmp/*.js ➞ Concatenate ➞ Save tmp/all.jsRead tmp/all.js ➞ Minify ➞ tmp/all.min.jsCopy tmp/all.min.js to dist/all.min.js
Gulp.js
Start reading src/*.coffeePipe through CoffeScript compilerPipe through ConcatPipe through MinifySave as dist/all.min.js
gulp.task('default', function () {gulp.src('src/*.coffee').pipe(coffee()).pipe(concat('all.min.js')).pipe(uglify()).pipe(gulp.dest('dist'));});
Gulp has like 4public methods(Are these programmers lazy or what?)
But it uses a lot oflibrariesAnd we will too
OrchestratorVinyl
VinylA virtual file format
Object that encapsulates the filesystemgulp.src() wrapper for vinyl.src()Also .dest()
CODE!
var through = require('through2');module.exports = function (name) {function log (file, enc, cb) {console.log(name, ":", file.path);cb(null, file);}return through.obj(log);};
gulp.task('default', function () {gulp.src('src/*.coffee').pipe(log("coffee")).pipe(coffee()).pipe(log("concat")).pipe(concat('all.min.js')).pipe(log("uglify")).pipe(uglify()).pipe(log("dest")).pipe(gulp.dest('dist'));});
github.com/substack/stream-handbookmedium.com/@contrahacks/gulp-3828e8126466speakerdeck.com/florianeckerstorfer
Questions?