joey-pie
3/2/2017 - 11:13 AM

Auto reload browser for any file change with gulp and browser sync

Auto reload browser for any file change with gulp and browser sync

/**
 * Auto reload on ANY php, js, html or css file change
 * 
 * Setup:
 * Add this file to your root directory 
 * Change example.dev to your local address
 * Run the following commands
 * - npm init
 * - npm install gulp browser-sync --save-dev
 * - gulp
 */
var gulp        = require('gulp');
var browserSync = require('browser-sync').create();

gulp.task('browser-sync', function() {
    var files = ['./**/*.php', './**/*.js', './**/*.css', './**/*.html'];
    browserSync.init( files, {
        proxy: "example.dev"
    });
});
gulp.task('default', ['browser-sync'], function() {
    gulp.watch("./**/*.php");
});