Last active
June 14, 2017 14:47
-
-
Save Rady/3aee569ed2cc2a79b5171df0d0d14a6c to your computer and use it in GitHub Desktop.
PHP Server gulpfile.js
This file contains hidden or 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
// grab all our packages | |
var gulp = require('gulp'); | |
var php = require('gulp-connect-php'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
var autoprefixer = require('gulp-autoprefixer'); | |
var sass = require('gulp-sass'); | |
var htmlmin = require('gulp-htmlmin'); | |
var autoprefixerOptions = { | |
browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] | |
}; | |
// create a task to serve the app | |
gulp.task('php', function() { | |
// start the php server | |
php.server({},function(){ | |
browserSync({ | |
proxy: '127.0.0.1:8000' | |
}); | |
}); | |
}); | |
// Static Server + watching scss/html files | |
gulp.task('serve', ['php'], function() { | |
gulp.watch("*.php").on('change', reload); | |
}); | |
gulp.task('minify', function() { | |
return gulp.src('*.html') | |
.pipe(htmlmin({collapseWhitespace: true})) | |
.pipe(gulp.dest('dist')) | |
}); | |
// Compile sass into CSS & auto-inject into browsers | |
gulp.task('sass', function() { | |
return gulp.src("sass/*.scss") | |
.pipe(sass({outputStyle: 'compressed'})) | |
.pipe(autoprefixer(autoprefixerOptions)) | |
.pipe(gulp.dest("css")) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('default', ['serve']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment