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

Improving development workflow with GruntJS

Improving development workflow with GruntJS

How grunt helps improve the workflow of developers for day to day tasks

Zaki Shaheen

August 07, 2014
Tweet

More Decks by Zaki Shaheen

Other Decks in Programming

Transcript

  1. @meetzaki Agenda • A typical developer workflow • Room for

    improvement • What is Grunt • Short intro to NodeJS • What is NPM • Installing Grunt • Grunt Modules • Demo • Yeoman and advanced tooling
  2. @meetzaki Pros • You are familiar with it. • You

    wont have to change anything. Cons • Its wasteful and sub-optimal. • Standards are not followed. • Performance is not ensured. Quality is not ensured.
  3. @meetzaki What about all this? Linting Preprocessors Unit testing Concatenation

    Minification Versioning Version control Dependencies
  4. @meetzaki What is GruntJS Task based CLI Tool Runs on

    NodeJS and NPM Massive Eco-system Your next best friend.
  5. @meetzaki Javascript out of the browser (Finally) Cross-platform runtime environment

    Built on Google’s V8 Engine Event-Driven, non-blocking i/o for real time apps Makes way for NPM
  6. @meetzaki Installing grunt npm install grunt-cli -g npm install grunt

    --save-dev What is Gruntfile.js load packages create custom commands
  7. @meetzaki module.exports = function(grunt) { // 1. All configuration goes

    here grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { // 2. Configuration for concatinating files goes here. } }); // 3. Where we tell Grunt we plan to use this plug-in. grunt.loadNpmTasks('grunt-contrib-concat'); // 4. Where we tell Grunt what to do when we type "grunt" into the terminal. grunt.registerTask('default', ['concat']); }; http://24ways.org/2013/grunt-is-not-weird-and-hard/
  8. @meetzaki concat: { dist: { src: [ 'js/libs/*.js', // All

    JS in the libs folder 'js/global.js' // This specific file ], dest: 'js/build/production.js', } }
  9. @meetzaki Who uses grunt? Who doesn’t? Who uses Grunt Twitter

    Bootstrap Gruntfile Wordpress build process Gruntfile
  10. @meetzaki Yeoman and advanced tooling seperate tasking for staging and

    production - don’t miss a step again http://yeoman.io http://chrisawren.com/posts/Advanced-Grunt- tooling
  11. @meetzaki • Enforce standards with csslint, jslint, phpmd, phpcpd, phpcs

    automatically • Automate testing with phpunit, qunit • Increase performance with cssmin, concat, uglify • See stats with pagespeed • improve and standardize deployments • Save your time and gain quality! • One more step closer to Continuous integration after introduction of vagrant Why Grunt?
  12. @meetzaki Next steps Identify what you do repeatedly Ask whether

    there is a grunt plugin for it automate it repeat