Last active
January 9, 2017 08:05
-
-
Save jaskiratr/88addaae43a37322d6c30e6a47c6f913 to your computer and use it in GitHub Desktop.
Express Gulp File
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
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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference : https://gist.github.com/dstroot/22525ae6e26109d3fc9d