Skip to content

Instantly share code, notes, and snippets.

@Adam-Collier
Created November 5, 2017 19:54
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var nodemon = require('gulp-nodemon');
var sass = require('gulp-sass');
gulp.task('browser-sync', ['nodemon'], function () {
browserSync({
proxy: "localhost:3000", // local node app address
port: 5000, // use *different* port than above
notify: true,
browser: "google chrome"
});
});
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
script: './bin/www',
ignore: [
'gulpfile.js',
'node_modules/'
]
})
.on('start', function () {
if (!called) {
called = true;
cb();
}
})
.on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
});
});
gulp.task('sass', function () {
gulp.src('./public/sass/main.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css'));
});
gulp.task('default', ['browser-sync'], function () {
gulp.watch('**/*.scss', ['sass']);
gulp.watch(['**/*.{css,html,pug}'], reload);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment