Created
December 25, 2016 23:32
-
-
Save jonathanwork/91a67bd60d734566b02c7a78f5cb764c to your computer and use it in GitHub Desktop.
reallly helpful gist to use with hapi and gulpfile with browserSync and nodemon
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
/** | |
* Module Dependencies | |
*/ | |
var gulp = require('gulp'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
var nodemon = require('gulp-nodemon'); | |
var g_sass = require('gulp-sass'); | |
var pug = require('gulp-pug'); | |
var css_files = [ | |
// this is the sass path | |
'./libs/**/*.sass' | |
// this is the css path | |
,'./public/css' | |
]; | |
var pug_files = [ | |
// this is the pug path | |
'./public/**/*.pug' | |
]; | |
/** | |
* Gulp Tasks | |
*/ | |
gulp.task('browser-sync', ['nodemon'], function() { | |
browserSync({ | |
proxy: "localhost:7000", // what do you want to proxy | |
port: 5000, // use *different* port than above | |
notify: true | |
}); | |
}); | |
gulp.task('nodemon', function (cb) { | |
var called = false; | |
return nodemon({ | |
script: 'bot_server.js' | |
,ext: 'js pug sass' | |
,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', ()=> { | |
return gulp.src(css_files[0]) | |
.pipe(gulp.dest(css_files[1])) | |
// .pipe(browserSync.reload) | |
}); | |
gulp.task("pug", ()=> { | |
return gulp.src(pug_files[0]) | |
.pipe(pug({pretty: true})) | |
}); | |
gulp.task('default', ['browser-sync', 'sass', 'pug'], function () { | |
gulp.watch([pug_files[0]], reload); | |
gulp.watch([css_files[0]], reload); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment