Created
October 23, 2015 07:24
-
-
Save murum/47b35085dfb603d56b82 to your computer and use it in GitHub Desktop.
Wordpress gulp with PHP browsersync
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
///// Plugin Includes ///// | |
var gulp = require('gulp'), | |
uglify = require('gulp-uglify'), | |
plumber = require('gulp-plumber'), | |
concat = require('gulp-concat'), | |
jshint = require('gulp-jshint'), | |
autoprefixer = require('gulp-autoprefixer'), | |
browserSync = require('browser-sync'), | |
reload = browserSync.reload, | |
sass = require('gulp-sass'); | |
///// Compile/Validate JS ///// | |
gulp.task('js', function () { | |
gulp.src('./js/app.js') | |
.pipe(plumber()) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default', { verbose: true })) | |
.pipe(concat('app.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./js/dist/')) | |
}); | |
///// Compile Sass ///// | |
gulp.task('sass', function () { | |
gulp.src('./scss/style.scss') | |
.pipe(plumber()) | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(sass( {outputStyle: 'compressed'} )) | |
.pipe(autoprefixer('last 2 versions')) | |
.pipe(gulp.dest('./')) | |
.pipe(browserSync.stream()) | |
}); | |
///// Get PHP ///// | |
gulp.task('php', function () { | |
gulp.src('./php/*.php') | |
.pipe(gulp.dest('./')) | |
}); | |
///// Browser Sync ///// | |
gulp.task('browser-sync', function () { | |
browserSync.init({ | |
proxy: "travellog.dev", | |
notify: false | |
}); | |
gulp.watch('./scss/**/*.scss', ['sass']); | |
gulp.watch('./js/app.js', ['js']).on('change', browserSync.reload); | |
gulp.watch('./php/*.php', ['php']).on('change', browserSync.reload); | |
}); | |
////////////////////////////// | |
// Default Task | |
////////////////////////////// | |
gulp.task('default', ['browser-sync']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment