Skip to content

Instantly share code, notes, and snippets.

@jaskiratr
Last active January 9, 2017 08:05
Show Gist options
  • Save jaskiratr/88addaae43a37322d6c30e6a47c6f913 to your computer and use it in GitHub Desktop.
Save jaskiratr/88addaae43a37322d6c30e6a47c6f913 to your computer and use it in GitHub Desktop.
Express Gulp File
var gulp = require('gulp');
var exec = require('child_process').exec;
var sass = require('gulp-sass');
var nodemon = require('gulp-nodemon');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
gulp.task('default', ['sass', 'browser-sync'], function() {
gulp.watch("public/scss/*.scss", ['sass'], reload);
gulp.watch(["views/**/*.pug", "./*.js"], reload);
});
// SASS Compiler
gulp.task('sass', function() {
gulp.src('./public/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css/'))
.pipe(reload({
stream: true
}));
});
//BrowserSync
gulp.task('browser-sync', ['nodemon'], function() {
browserSync.init(null, {
proxy: "http://localhost:8080",
port: 3000,
reloadDelay: 1000
});
});
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
script: 'app.js',
ignore: [
'gulpfile.js',
'node_modules/'
]
})
.on('start', function () {
if (!called) {
called = true;
cb();
}
})
.on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
});
});
@jaskiratr
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment