Last active
September 22, 2015 22:08
-
-
Save estevanmaito/c6a99d44d265c63f3bb9 to your computer and use it in GitHub Desktop.
Gulp plugins
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
var gulp = require('gulp'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
var prefixer = require('gulp-autoprefixer'); | |
var changed = require('gulp-changed'); | |
var imagemin = require('gulp-imagemin'); | |
var jshint = require('gulp-jshint'); | |
var stylish = require('jshint-stylish'); | |
var minifycss = require('gulp-minify-css'); | |
var minifyhtml = require('gulp-minify-html'); | |
var sass = require('gulp-sass'); | |
var uglify = require('gulp-uglify'); | |
gulp.task('css', function() { | |
gulp.src('./src/sass/*.scss') | |
.pipe(changed('./dist/css')) | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(prefixer()) | |
.pipe(minifycss()) | |
.pipe(gulp.dest('./dist/css')) | |
.pipe(reload({stream: true})); | |
}); | |
gulp.task('lint', function() { | |
gulp.src('./src/js/*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter(stylish)); | |
}); | |
gulp.task('js', function() { | |
gulp.src('./src/js/*.js') | |
.pipe(changed('./dist/js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./dist/js')) | |
.pipe(reload({stream: true})); | |
}); | |
gulp.task('html', function() { | |
gulp.src('./src/*.html') | |
.pipe(changed('./dist')) | |
.pipe(minifyhtml()) | |
.pipe(gulp.dest('./dist')) | |
.pipe(reload({stream: true})); | |
}); | |
gulp.task('imagemin', function() { | |
gulp.src('./src/img/*') | |
.pipe(changed('./dist/img')) | |
.pipe(imagemin({progressive: true})) | |
.pipe(gulp.dest('./dist/img')); | |
}); | |
gulp.task('browserSync', function() { | |
browserSync({ | |
server: { | |
baseDir: './dist' | |
}, | |
port: 8080, | |
open: true, | |
notify: false | |
}); | |
}); | |
gulp.task('watcher',function(){ | |
gulp.watch('./src/*.html', ['html']); | |
gulp.watch('./src/sass/*.scss', ['css']); | |
gulp.watch('./src/js/*.js', ['lint']); | |
gulp.watch('./src/js/*.js', ['js']); | |
gulp.watch('./src/img/*', ['js']); | |
}); | |
gulp.task('default', ['watcher', 'browserSync']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment