Skip to content

Instantly share code, notes, and snippets.

@vmdao
Created July 15, 2016 10:43
Show Gist options
  • Save vmdao/08af7bbb7334fc3c7d103c51655aeaca to your computer and use it in GitHub Desktop.
Save vmdao/08af7bbb7334fc3c7d103c51655aeaca to your computer and use it in GitHub Desktop.
------------
// app.js
'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');
});
------------
gulpfile.js
'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) {
var started = false;
return nodemon({
script: 'app.js'
}).on('start', function () {
// to avoid nodemon being started multiple times
// thanks @matthisk
if (!started) {
cb();
started = true;
}
});
});
app.listen(5000);
----------
ref: https://gist.github.com/sogko/b53d33d4f3b40d3b4b2e | https://gist.github.com/kevinSuttle/c8b198aaa30349088c35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment