Last active
January 25, 2018 14:47
-
-
Save eioo/d9df057addfa9e520fb1d153f1c579cd to your computer and use it in GitHub Desktop.
Gulp + Express + Nodemon + Browser-sync in harmony
This file contains 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
const express = require('express'); | |
const app = express(); | |
const router = express.Router(); | |
app.use(express.static('public')); | |
app.listen(3000); |
This file contains 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
const gulp = require('gulp'); | |
const browserSync = require('browser-sync'); | |
const nodemon = require('gulp-nodemon'); | |
gulp.task('default', ['browser-sync'], () => { | |
}); | |
gulp.task('browser-sync', ['nodemon'], () => { | |
browserSync.init(null, { | |
proxy: "http://localhost:3000", | |
files: ["public/**/*.*"], | |
port: 5000 | |
}); | |
}); | |
gulp.task('nodemon', (callback) => { | |
let started = false; | |
return nodemon({ | |
script: 'app.js' | |
}).on('start', () => { | |
if (!started) { | |
callback(); | |
started = true; | |
} | |
}); | |
}); |
This file contains 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
<!-- This should be in './public' directory --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Page Title</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains 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": "gulp-express-nodemon-browsersync", | |
"version": "0.0.0", | |
"description": "", | |
"main": "app.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"license": "ISC", | |
"dependencies": { | |
"express": "^4.8.2" | |
}, | |
"devDependencies": { | |
"browser-sync": "^1.3.3", | |
"gulp": "^3.8.7", | |
"gulp-nodemon": "^1.0.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @sogko. I modified it a bit to fit better for my needs.