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

Improving your workflow with Gulp

Improving your workflow with Gulp

Improving your workflow with Gulp

Frontend NE

July 02, 2015
Tweet

More Decks by Frontend NE

Other Decks in Technology

Transcript

  1. Improving your workflow • Why should you use gulp? •

    gulp API • gulp vs Grunt • The power of gulp • The future of gulp • Gotchas • Questions at the end
  2. Quick Facts • 44,000 downloads a day • Used by

    ◦ Bede Gaming ◦ Google ◦ Netflix ◦ Soundcloud • Uses Node.js and Orchestrator.js • It’s open source!
  3. Why another task runner? • gulp aims to be simple

    for users • gulp plugins should do one thing well • Can work with existing node modules • Grunt was great but did a few things wrong...
  4. Streams? “If you dig a trench on a hill and

    fill up the high end using a water hose the water will run down the hill along the trench” Tim Caswell - HowToNode.org
  5. • Streams use ‘pipes’, which allow us to pass data

    through the stream. • • • Streams are what makes gulp fast Streams?
  6. Why use gulp? • Code over config • Minimal API

    • Uses streams • Runs with maximum concurrency
  7. Maximum Concurrency • Runs tasks together using orchestrator • Can

    minify your js and css at the same time • Speed!!!
  8. Why use gulp? • Code over config • Minimal API

    • Uses streams • Runs with maximum concurrency • Fast!
  9. gulp.task • Define a task name • Set dependencies if

    required • Can run multiple plugins main.scss sass autoprefix min main.css
  10. gulp.src • Specify the file to be processed • Can

    be a string or an array of files • Can change the base of the file • Accepts globbing - **/*.scss
  11. gulp.dest • Where the processed file should be saved •

    Can be used with src’s base option
  12. gulp • Uses streams • Easy to maintain • Fast!

    • Runs concurrently • Fast growing Grunt vs
  13. gulp • Uses streams • Easy to maintain • Fast!

    • Runs concurrently • Fast growing Grunt vs • Has to run in order • Difficult to maintain • Slow(er)! • Writes to Temp files • More plugins • Paved the way
  14. Task runners at Bede • Switched to gulp in August

    2014 • Build times were almost twice as fast with twice as many files to process • Can use arrays instead of specifying each file • gulp in TeamCity for build tasks
  15. The power of gulp • gulp can run a lot

    of tasks and processes easily and very fast • Html minification, css minification, js linting, image compression, clean files, browserify bundles… • Can use plugins without importing each one
  16. The future of gulp • gulp 4 is in the

    line • • • ES6 • Error handling!
  17. Gotchas • Error handling • Errors break the stream, cancelling

    the task • Can be intimidating • Easy to rely on gulp plugins
  18. Summary • Why should you use gulp? • Minimal API

    • gulp vs Grunt • The power of gulp • The future of gulp • Gotchas