Better gulp

This commit is contained in:
Dan Seripap 2016-01-10 16:30:05 -05:00
parent 9958bfd9a1
commit 7f0993182d
5 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,6 @@
var gulp = require('gulp'); var gulp = require('gulp');
var uglify = require('gulp-uglify'); var uglify = require('gulp-uglify');
var nodemon = require('gulp-nodemon');
gulp.task('watch', function() { gulp.task('watch', function() {
gulp.watch('src/js/main.js', ['build']); gulp.watch('src/js/main.js', ['build']);
@ -12,3 +13,15 @@ gulp.task('uglify', function() {
.pipe(uglify()) .pipe(uglify())
.pipe(gulp.dest('src/public')); .pipe(gulp.dest('src/public'));
}); });
gulp.task('start', function() {
nodemon({
script: 'index.js',
ext: 'css js mustache',
ignore: ['src/public/main.js'],
env: {
'NODE_ENV': 'development'
},
tasks: ['build']
})
})

View File

@ -18,7 +18,9 @@
"underscore": "^1.8.3", "underscore": "^1.8.3",
"uuid": "^2.0.1" "uuid": "^2.0.1"
}, },
"devDependencies": {}, "devDependencies": {
"gulp-nodemon": "^2.0.6"
},
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"jsbuild": "uglifyjs src/js/main.js --compress --mangle -o src/public/main.js" "jsbuild": "uglifyjs src/js/main.js --compress --mangle -o src/public/main.js"

View File

@ -11,12 +11,7 @@ Install dependencies
You need Gulp installed globally: You need Gulp installed globally:
npm install -g gulp npm install -g gulp
gulp watch gulp start
Run the app (nodemon is nice to have)
npm install -g nodemon
nodemon --watch src index.js -e css,js,mustache
FattyChat is now running on `http://localhost:3000` FattyChat is now running on `http://localhost:3000`

View File

@ -25,6 +25,7 @@ $(function() {
var $key = $('#key'); var $key = $('#key');
var $genKey = $('.new_key'); var $genKey = $('.new_key');
var $removeKey = $('#remove_key'); var $removeKey = $('#remove_key');
var $participants = $('#participants');
var $chatPage = $('.chat.page'); // The chatroom page var $chatPage = $('.chat.page'); // The chatroom page
@ -49,11 +50,17 @@ $(function() {
function addParticipantsMessage (data) { function addParticipantsMessage (data) {
var message = ''; var message = '';
var headerMsg = '';
if (data.numUsers === 1) { if (data.numUsers === 1) {
message += "There's 1 participant"; message += "There's 1 participant";
headerMsg = "1 Participant";
} else { } else {
message += "There are " + data.numUsers + " participants"; message += "There are " + data.numUsers + " participants";
headerMsg = data.numUsers + " participants";
} }
$participants.text(headerMsg);
log(message); log(message);
} }

View File

@ -24,7 +24,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="#">FattyChat</a> <a class="navbar-brand" href="#">FattyChat</a> <small id="participants"></small>
</div> </div>
<!-- Collect the nav links, forms, and other content for toggling --> <!-- Collect the nav links, forms, and other content for toggling -->