29. NodeJS
- Grunt and Gulp both run on a local
NodeJS server.
- You don’t need to know any NodeJS!
- Install from here: nodejs.org
- Easy to install (even on Windows)
30. Package.json
- Keeps a list of dependencies we’re
using.
- Create a new one with:
npm init
31.
32. Tasks
- Configure Grunt and Gulp with tasks.
- Finding New Tasks:
- Google ‘grunt’/‘gulp’ and the task.
- Search http://npmjs.org
33. Adding a New Task
- Everytime we add a new task, we
should add it to package.json
npm install example --save-dev
41. Install Gulp
- Install Gulp globally for command line
and then locally for our package.json
npm install -g gulp
npm install gulp --save-dev
42. Creating a Gulpfile
- Gulpfile.js
'use strict';
!
var gulp = require('gulp');
// Set variables to each required task/plugins
var example = require('gulp-example');
!
gulp.task('example', function() {
// Task configuration
return gulp.src(‘/src/files')
.pipe(something())
.pipe(gulp.dest(‘/dist/files'));
});
!
// Register a set of tasks to run
gulp.task(‘default', ['example']);
58. Auto Load Tasks (Gulp)
var connect = require(‘gulp-connect’);
var jshint = require(‘gulp-jshint’);
var concat = require(‘gulp-concat’);
var plugins = require(‘gulp-load-plugins’)();
// plugins.jshint
Before:
After: