Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hello Gulp

Hello Gulp

An introduction to gulp: https://github.com/hilios/hello-gulp

Edson Hilios

June 13, 2014
Tweet

More Decks by Edson Hilios

Other Decks in Programming

Transcript

  1. Build system • Pre-compilers: LESS, SASS, CoffeeScript; • Automate repetitive

    tasks; • Optimize files for production / deploy; • Ease development workflow;
  2. Summary • Minimal API; • Automate tasks; • Stream IO;

    • Flow control: Async / Sync; • Built-in watch;
  3. API • Code over configuration; • Plain JS and Node;

    • ~30% less code; • Easier to split in several files; • Easier to hack and extend;
  4. Output $ gulp build [gulp] Using gulpfile /gulpfile.js [gulp] Starting

    'build'... [gulp] Finished 'build' after 6.81 ms
  5. Tasks // Task with dependencies gulp.task('name', ['dependency1', ...], function() {

    ... }); // Task alias gulp.task('name', ['dependency1', ...]); // 'Default' task => $ gulp gulp.task('default', ['lint', 'build', 'less']);
  6. By default, tasks run with maximum concurrency -- e.g. it

    launches all the tasks at once and waits for nothing. – Gulp API documentation
  7. Plugins • gulp-concat • gulp-rename • gulp-jshint • gulp-karma •

    gulp-less • gulp-coffee • gulp-include • gulp-uglify • gulp-zip • gulp-bump https://www.npmjs.org/search?q=gulp-*
  8. Caveats // Load a config file var config = require('config.json');

    gulp.task('build', function(done) { gulp.src(config.js) .pipe(...); });
  9. Caveats var util = require('gulp-util'); // Emit sound util.beep(); //

    Log with color util.log(); // Lo-dash template util.template();
  10. Caveats var karma = require('karma').server; gulp.task('test', function(done) { karma.start({ configFile:

    __dirname + '/karma.conf.js' }, function(exitCode) { done(exitCode); }); });