Skip to content

Instantly share code, notes, and snippets.

@dstroot
Created July 13, 2014 16:29
Show Gist options
  • Save dstroot/22525ae6e26109d3fc9d to your computer and use it in GitHub Desktop.
Save dstroot/22525ae6e26109d3fc9d to your computer and use it in GitHub Desktop.

Revisions

  1. dstroot created this gist Jul 13, 2014.
    13 changes: 13 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    /**
    * World's simplest express server
    * - used to serve index.html from /public
    */

    var express = require('express');
    var serveStatic = require('serve-static');
    var app = express();

    app.use(serveStatic(__dirname + '/public'));

    app.listen(3000);
    console.log('Express listening on port 3000');
    46 changes: 46 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    /**
    * Module Dependencies
    */

    var gulp = require('gulp');
    var browserSync = require('browser-sync');
    var reload = browserSync.reload;
    var nodemon = require('gulp-nodemon');

    /**
    * Gulp Tasks
    */

    gulp.task('browser-sync', ['nodemon'], function() {
    browserSync({
    proxy: "localhost:3000", // local node app address
    port: 5000, // use *different* port than above
    notify: true
    });
    });

    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);
    });
    });

    gulp.task('default', ['browser-sync'], function () {
    gulp.watch(['public/*.html'], reload);
    });
    12 changes: 12 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    {
    "private": true,
    "dependencies": {
    "express": "^4.5.1",
    "serve-static": "^1.3.0"
    },
    "devDependencies": {
    "browser-sync": "^1.2.1",
    "gulp": "^3.8.6",
    "gulp-nodemon": "^1.0.4"
    }
    }