Created
May 9, 2017 09:22
-
-
Save evanre/bd549577d2656e65356f8cefbcd64969 to your computer and use it in GitHub Desktop.
Wordpress 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
var | |
// global | |
gulp = require('gulp'), | |
watch = require('gulp-watch'), | |
browserSync = require("browser-sync"), | |
reload = browserSync.reload, | |
sass = require('gulp-sass'), | |
prefixer = require('gulp-autoprefixer'), | |
cssnano = require('gulp-cssnano'), | |
cmq = require('gulp-group-css-media-queries'); | |
function swallowError(error) { | |
console.log(error.toString()); | |
this.emit('end'); | |
} | |
gulp.task('style:build', function () { // Compile CSS; | |
return gulp.src('assets/style/style.scss') | |
.pipe(sass()) // Compile SASS; | |
.on('error', swallowError) | |
.pipe(cmq()) | |
.pipe(prefixer({browsers: ['last 3 versions'], cascade: false})) | |
//.pipe(cssnano()) | |
// .pipe(cssnano({ | |
// autoprefixer: { | |
// add: true, | |
// browsers: ['> 3%', 'last 2 versions', 'ie 9', 'ios 6', 'android 4'] | |
// }})) | |
.pipe(gulp.dest('./')) | |
.pipe(reload({stream: true})); | |
}); | |
gulp.task('build', ['style:build']); | |
gulp.task('watch', function () { // Watch for file changes; | |
watch('**/*.php', reload); | |
watch('assets/js/**/*.js', reload); | |
watch('assets/style/**/*.scss', function (event, cb) { | |
gulp.start('style:build'); | |
}); | |
}); | |
gulp.task('webserver', function () { // Start local web server; | |
browserSync({ | |
proxy: "http://eugenezhuchenko.dev", // Different for each project!! | |
//tunnel: true, | |
host: 'localhost', | |
port: 9000, | |
logPrefix: "Frontend_Evanre_Log" | |
}); | |
}); | |
gulp.task('build-watch', ['build', 'watch']); | |
gulp.task('default', ['build', 'webserver', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment