Automated Tasks
with Gulp
Cristian Cota


What is Gulp?
Is a toolkit for automating painful or time-consuming tasks in your development workflow.

$ npm init -ypackage.json
{
"name": "test-npm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
$ npm install Installing gulp
$ npm install --global gulp
$ gulp -vglobally
$ npm install --save-dev gulp
$ gulp -vlocally
gulpfile.js
var gulp = require('gulp');-
gulp.task
-
gulp.src
-
gulp.dest
-
gulp.watch
var gulp = require('gulp');
gulp.task('mytask', function() {
//do stuff
});gulpfile.js
Pipe method
"The readable.pipe() method attaches a Writable stream to the readable, causing it to switch automatically into flowing mode and push all of its data to the attached Writable. The flow of data will be automatically managed so that the destination Writable stream is not overwhelmed by a faster Readable stream."
var gulp = require('gulp');
gulp.task('copy', function() {
gulp.src('source/*').pipe(gulp.dest('destination'));
});gulpfile.js
var gulp = require('gulp');
gulp.task('listenJs', function() {
gulp.watch('js/*.js', ['sayHi']);
});
gulp.task('sayHi', function() {
console.log('Hola')
});gulpfile.js
var gulp = require('gulp');
gulp.task('default', function() {
gulp.watch('js/*.js', ['sayHi']);
});
gulp.task('sayHi', function() {
console.log('Hola')
});gulpfile.js

$ npm install --save-dev gulp-less @primary: #1C3C43;
@secondary: #2B7E7C;
@third: #F1EC99;
@black-color: #000;
@white-color: #FFF;
html{
body{
background-color: @secondary;
p{
color: @third;
}
h1{
color: @primary;
}
.jumbotron{
color: orange;
}
}
}

$ npm install --save-dev gulp-pugMinify/uglify
$ npm install --save-dev gulp-uglify
$ npm install --save-dev gulp-cssoConcat
$ npm install --save-dev gulp-concatbrowserSync
$ npm install --save-dev browser-sync
$ npm install --save-dev karmaccota@nearsoft.com
cbojorquez@nearsoft.com
Automated Tasks
By Cristian Cota
Automated Tasks
- 198