Skip to content

Instantly share code, notes, and snippets.

@miziomon
Created August 26, 2015 09:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save miziomon/36e5741207b2a9ca2de7 to your computer and use it in GitHub Desktop.
Save miziomon/36e5741207b2a9ca2de7 to your computer and use it in GitHub Desktop.
my gulp config
/*
* https://github.com/gulpjs/gulp
* http://code.tutsplus.com/tutorials/using-gulp-for-wordpress-automation--cms-23081
* https://markgoodyear.com/2014/01/getting-started-with-gulp/
* http://mattbanks.me/gulp-wordpress-development/
*
*/
var gulp = require('gulp'),
through = require('gulp-through'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
stylish = require('jshint-stylish'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
cache = require('gulp-cache'),
sass = require('gulp-sass'),
minifyCss = require('gulp-minify-css'),
livereload = require('gulp-livereload');
gulp.task('watch', function () {
livereload.listen();
gulp.watch('sass/*.scss', ['sass']);
gulp.watch('javascripts/*.js', ['js']);
gulp.watch('images-source/*.{png,jpg,gif}', ['img']);
gulp.watch('**/*.php', ['php']);
});
gulp.task('php', function () {
return gulp.src('index.php')
.pipe(notify("Hello Gulp!"))
.pipe(livereload());
});
gulp.task('sass', function () {
gulp.src('sass/*.scss')
.pipe(plumber({errorHandler: notify.onError("SASS Error: <%= error.message %>")}))
.pipe(sass())
.pipe(minifyCss({compatibility: 'ie8', keepSpecialComments: 1}))
.pipe(gulp.dest('css'))
.pipe(livereload());
});
gulp.task('js', function () {
return gulp.src('javascripts/*.js')
.pipe(plumber())
.pipe(jscs({fix: true, preset: "wordpress", }))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'))
.pipe(uglify())
.pipe(concat('theme.min.js'))
.pipe(gulp.dest(''))
.pipe(livereload())
});
gulp.task('img', function () {
gulp.src('images-source/*.{png,jpg,gif}')
.pipe(plumber({errorHandler: notify.onError("Image Error: <%= error.message %>")}))
.pipe(cache(imagemin({optimizationLevel: 5, progressive: true, interlaced: true})))
.pipe(gulp.dest('images'))
.pipe(livereload());
});
gulp.task('default', ['sass', 'js', 'img', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment