Task automation with Grunt.js

Nguyen Tien Si

GO1

Agenda

  • Why use a task runner & Grunt?

  • Introduction

  • Demo

  • Question?

Why?

  • Automation.

  • Resolve repetitive tasks.

  • Grunt is growing every day.

  • Many plugins.

  • Many companies and projects that use Grunt.

Introduction

Which developer never wasted time doing repetitive and boring tasks instead of being focused on what we do best "Code".

Installing & Configuring

# Installing GruntJS

npm install -g grunt-cli
// Configuring GruntJS (Gruntfile.js)

module.exports = function(grunt) {

  // Load all plugins and tasks defined by the grunt-drupal-tasks package.
  require('grunt-drupal-tasks')(grunt);

};

Installing & Configuring

{
  "name": "grunt-drupal-tasks-example",
  "description": "Example package.json for a Drupal 
                  project built with grunt-drupal-tasks.",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "grunt": "~0.4.5",
    "grunt-drupal-tasks": "~0.6.0",
    "zombie": "^2.5.1"
  }
}

Demo

Running "newer:drushmake:default" (newer) task
No newer files to process.

Running "scaffold" task
Detected Drupal 7 codebase.

Running "symlink:profiles" (symlink) task
>> Created 0 symbolic links.

Running "symlink:modules" (symlink) task
>> Created 1 symbolic links.

Running "symlink:themes" (symlink) task
>> Created 1 symbolic links.

Running "copy:defaults" (copy) task
Copied 1 file

Running "clean:sites" (clean) task
>> 1 path cleaned.

Running "symlink:sites" (symlink) task
>> Created 1 symbolic links.

Running "mkdir:files" (mkdir) task
Creating "build/html/sites/default/files"...OK

Running "copy:static" (copy) task
Created 1 directory, copied 1 file

Done, without errors.

References

  • http://gruntjs.com

  • https://github.com/phase2/grunt-drupal-tasks

Question?

Task automation with Grunt.js

By Nguyen Tien Si

Task automation with Grunt.js

  • 887