Created
November 22, 2015 22:11
-
-
Save pablocampina/9b2e333d908b9e49a8aa to your computer and use it in GitHub Desktop.
My Gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LOAD PLUGINS | |
var gulp = require('gulp'); | |
var minifyCss = require('gulp-minify-css'); | |
var jshint = require('gulp-jshint'); | |
var uglify = require('gulp-uglify'); | |
var concat = require('gulp-concat'); | |
var cache = require('gulp-cache'); | |
var imagemin = require('gulp-imagemin'); | |
var rename = require('gulp-rename'); | |
var notify = require('gulp-notify'); | |
var livereload = require('gulp-livereload'); | |
// PATHS | |
var paths = { | |
styles: '../_dev/css/*.css', | |
scripts: '../_dev/js/**/*.js', | |
images: '../_dev/images/**/*' | |
}; | |
// STYLES | |
gulp.task('styles', function() { | |
return gulp.src(paths.styles) | |
.pipe(minifyCss()) | |
.pipe(rename({ suffix: '.min' })) | |
.pipe(gulp.dest('../_/css')) | |
.pipe(notify('A tarefa STYLES está completa!')); | |
}); | |
// SCRIPTS | |
gulp.task('scripts', function() { | |
return gulp.src(paths.scripts) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')) | |
.pipe(rename({ suffix: '.min' })) | |
.pipe(concat('main.js')) | |
.pipe(gulp.dest('../_/js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('../_/js')) | |
.pipe(notify('A tarefa SCRIPTS está completa!')); | |
}); | |
// IMAGES | |
gulp.task('images', function() { | |
return gulp.src(paths.images) | |
.pipe(cache(imagemin({ optimizationLevel: 7, progressive: true, interlaced: true }))) | |
.pipe(gulp.dest('../_/images')) | |
.pipe(notify('A tarefa IMAGES está completa!')); | |
}); | |
// RERUN THE TASK WHEN A FILE CHANGES | |
gulp.task('watch', function() { | |
gulp.watch(paths.styles, ['styles']); | |
gulp.watch(paths.scripts, ['scripts']); | |
gulp.watch(paths.images, ['images']); | |
livereload.listen(); | |
gulp.watch(['../_/**']).on('change', livereload.changed); | |
}); | |
// DEFAULT TASK | |
gulp.task('default', ['watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment