Created
March 9, 2016 18:00
-
-
Save wesbos/12413f4684ac5e64f232 to your computer and use it in GitHub Desktop.
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'), | |
browserSync = require('browser-sync'), | |
reload = browserSync.reload, | |
autoprefixer = require('gulp-autoprefixer'), | |
concat = require('gulp-concat'), | |
imageMin = require('gulp-imagemin'), | |
minifyCSS = require('gulp-minify-css'), | |
notify = require('gulp-notify'), | |
plumber = require('gulp-plumber'), | |
sass = require('gulp-sass'), | |
sourcemaps = require('gulp-sourcemaps'), | |
uglify = require('gulp-uglify'); | |
gulp.task('bs', function() { | |
browserSync.init({ | |
/* | |
Heads Up: | |
This assumes your are running WordPress fine on port 80 with something like MAMP or XAMP | |
You might need to change this to localhost:8888 if you are running on a different port | |
*/ | |
proxy: 'http://localhost' | |
}); | |
}); | |
gulp.task('styles', function() { | |
return gulp.src('./sass/**/*.scss') | |
.pipe(plumber({ | |
errorHandler: notify.onError("Error: <%= error.message %>") | |
})) | |
.pipe(sourcemaps.init()) | |
.pipe(sass()) | |
.pipe(minifyCSS()) | |
.pipe(concat('style.css')) | |
.pipe(autoprefixer('last 5 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1')) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest('./')) | |
.pipe(reload({ stream: true })); | |
}); | |
gulp.task('scripts', function () { | |
return gulp.src('./js/scripts.js') | |
.pipe(plumber({ | |
errorHandler: notify.onError("Error: <%= error.message %>") | |
})) | |
.pipe(concat('main.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./js')) | |
.pipe(reload({stream:true})); | |
}); | |
gulp.task('images', function () { | |
return gulp.src('./images/**/*') | |
.pipe(imageMin()) | |
.pipe(gulp.dest('./images')); | |
}); | |
// configure which files to watch and what tasks to use on file changes | |
gulp.task('watch', function() { | |
gulp.watch('sass/**/*.scss', ['styles']); | |
gulp.watch('./js/**/*.js', ['scripts']); | |
gulp.watch('./**/*.php', reload); | |
}); | |
gulp.task('default', ['styles', 'scripts', 'images', 'bs', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I have got work conception now :D