Skip to content

Instantly share code, notes, and snippets.

@selvinortiz
Forked from sogko/app.js
Created July 31, 2016 05:39
Show Gist options
  • Select an option

  • Save selvinortiz/c266e907c42b92f67833220bb5d9b933 to your computer and use it in GitHub Desktop.

Select an option

Save selvinortiz/c266e907c42b92f67833220bb5d9b933 to your computer and use it in GitHub Desktop.

Revisions

  1. @sogko sogko revised this gist Jul 3, 2015. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ var gulp = require('gulp');
    var browserSync = require('browser-sync');
    var nodemon = require('gulp-nodemon');


    gulp.task('default', ['browser-sync'], function () {
    });

    @@ -15,11 +16,18 @@ gulp.task('browser-sync', ['nodemon'], function() {
    port: 7000,
    });
    });

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

    var started = false;

    return nodemon({
    script: 'app.js'
    script: 'app.js'
    }).on('start', function () {
    cb();
    });
    // to avoid nodemon being started multiple times
    // thanks @matthisk
    if (!started) {
    cb();
    started = true;
    }
    });
    });
  2. @sogko sogko created this gist Aug 10, 2014.
    13 changes: 13 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    'use strict';

    // simple express server
    var express = require('express');
    var app = express();
    var router = express.Router();

    app.use(express.static('public'));
    app.get('/', function(req, res) {
    res.sendfile('./public/index.html');
    });

    app.listen(5000);
    25 changes: 25 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    'use strict';

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

    gulp.task('default', ['browser-sync'], function () {
    });

    gulp.task('browser-sync', ['nodemon'], function() {
    browserSync.init(null, {
    proxy: "http://localhost:5000",
    files: ["public/**/*.*"],
    browser: "google chrome",
    port: 7000,
    });
    });

    gulp.task('nodemon', function (cb) {
    return nodemon({
    script: 'app.js'
    }).on('start', function () {
    cb();
    });
    });
    10 changes: 10 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <html>
    <head>
    <link rel="stylesheet" href="site.css"/>
    </head>
    <body>
    <!-- some dummy non-conforming quick dirty html code to test browser-sync. dont't judge me. -->
    <b>lorem</b> ipsum upsum dumsum
    </body>
    </html>
    <!-- put this under /public/* -->
    23 changes: 23 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    {
    "name": "gulp-expressjs-nodemon-browser-sync",
    "version": "0.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": {
    "name": "Hafiz Ismail",
    "email": "hafiz@wehavefaces.net",
    "url": "http://wehavefaces.net"
    },
    "license": "ISC",
    "dependencies": {
    "express": "^4.8.2"
    },
    "devDependencies": {
    "browser-sync": "^1.3.3",
    "gulp": "^3.8.7",
    "gulp-nodemon": "^1.0.4"
    }
    }
    7 changes: 7 additions & 0 deletions site.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    /* some css */
    /* put this under /public/* */
    body {
    font-family: 'Helvetica';
    color: red;
    font-size:24px;
    }