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.

Revisions

  1. jaskiratr revised this gist Jan 9, 2017. 1 changed file with 19 additions and 3 deletions.
    22 changes: 19 additions & 3 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -31,9 +31,25 @@ gulp.task('browser-sync', ['nodemon'], function() {

    });

    gulp.task('nodemon', function(cb) {

    gulp.task('nodemon', function (cb) {
    var called = false;
    return nodemon({
    script: 'app.js'
    }).once('start', cb);
    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);
    });
    });
  2. jaskiratr created this gist Jan 9, 2017.
    39 changes: 39 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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'
    }).once('start', cb);
    });