Created
July 28, 2017 06:44
-
-
Save pramodmg/6d9cad3289423741c7ab5ffb357532f3 to your computer and use it in GitHub Desktop.
A simple Gulp + browser-sync + express
This file contains hidden or 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
'use strict'; | |
// simple express server | |
var express = require('express'); | |
var app = express(); | |
var router = express.Router(); | |
var port = 5001; | |
app.use(express.static('public')); | |
app.get('/', function (req, res) { | |
res.sendfile('./public/index.html'); | |
// res.send('Hello world'); // to check the data is being passed to the UI | |
}); | |
app.listen(port, function () { | |
console.log('the port that it is listening to us ', port); | |
}); |
This file contains hidden or 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
'use strict'; | |
var gulp = require('gulp'); | |
var browserSync = require('browser-sync'); | |
var nodemon = require('gulp-nodemon'); | |
gulp.task('default', ['browser-sync']); | |
gulp.task('browser-sync', ['nodemon'], function () { | |
browserSync.init(null, { | |
proxy: "http://localhost:5001", | |
files: ["public/**/*.*"], | |
browser: "google chrome", | |
port: 7008, | |
}); | |
}); | |
gulp.task('nodemon', function (cb) { | |
var start = false; | |
return nodemon({ | |
script: 'app.js' | |
}).on('start', function () { | |
if (!started) { | |
cb(); | |
start = true; | |
} | |
}); | |
}); |
This file contains hidden or 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
/* please keep this file in the public directory */ | |
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<link rel="stylesheet" href="style.css" /> | |
</head> | |
<body> | |
<p> A simple HTML PAGE </p> | |
</body> | |
</html> |
This file contains hidden or 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
{ | |
"name": "Simple-Try", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"browser-sync": "^2.18.13", | |
"gulp": "^3.9.1", | |
"gulp-nodemon": "^2.2.1" | |
}, | |
"dependencies": { | |
"express": "^4.15.3" | |
} | |
} |
This file contains hidden or 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
body { | |
background: #e1e1e1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment