From fe1a3de4bf724ed5c33291437d89009eef3793e8 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 3 Oct 2014 11:33:06 +0900 Subject: [PATCH] Fixing autoreload --- gulpfile.js | 26 ++++++++++++++++++-------- server/server.js | 6 +++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2a9a9cd..400e5c0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -71,32 +71,42 @@ gulp.task('scripts', function() { gulp.task('styles', function() { var styles = getBowerFiles('.css').concat(['client/styles/*.css']); - console.log(styles); return gulp.src(styles).pipe(replace('../fonts/', './fonts/')).pipe(concat('styles.css')).pipe(minifyCss()).pipe(gulp.dest('client/dist')); }); -gulp.task('html_dev', function() { +gulp.task('html_dev', ['lint'], function() { var sources = gulp.src(getBowerFiles('.css').concat(getBowerFiles('.js')).concat(['client/scripts/*.js', 'client/styles/*.css']), {read: false}); var target = 'client/html/index.html'; var options = {addRootSlash: false, ignorePath: 'client'}; return gulp.src(target).pipe(inject(sources, options)).pipe(gulp.dest('client')); }); -gulp.task('html_dist', ['fonts', 'images', 'scripts', 'styles'], function() { +gulp.task('html_dist', ['lint', 'fonts', 'images', 'scripts', 'styles'], function() { var sources = gulp.src(['client/dist/*.js', 'client/dist/*.css'], {read: false}); var options = {addRootSlash: false, ignorePath: 'client/dist'}; var target = 'client/html/index.html'; return gulp.src(target).pipe(inject(sources, options)).pipe(minifyHtml()).pipe(gulp.dest('client/dist')); }); -gulp.task('dev', ['lint', 'html_dev'], function() { - var options = {script: 'server/server.js', ext: 'js', port: 8000, args: ['client']}; - return nodemon(options).on('change', ['lint']); +gulp.task('dev', ['html_dev'], function() { + var options = { + script: 'server/server.js', + ext: 'js html', + ignore: ['client/index.html'], + args: ['client'] + }; + + return nodemon(options).on('change', ['html_dev']); }); gulp.task('dist', ['html_dist'], function() { - var options = {script: 'server/server.js', ext: 'js', port: 8000, args: ['client/dist']}; - return nodemon(options).on('change', ['lint']); + var options = { + script: 'server/server.js', + ext: 'js html css', + ignore: ['client/dist/*'], + args: ['client/dist'] + }; + return nodemon(options).on('change', ['html_dist']); }); gulp.task('default', ['dev']); diff --git a/server/server.js b/server/server.js index 7a9d365..a88dd33 100755 --- a/server/server.js +++ b/server/server.js @@ -33,7 +33,7 @@ var express = require('express'); var path = require('path'); var search = require('./search.js'); -function main(staticFiles) { +function main(staticFiles, port) { var app = express(); search.loadDb({ @@ -67,9 +67,9 @@ function main(staticFiles) { }); app.use(express.static(path.join(__dirname, '..', staticFiles))); - app.listen(3000); + app.listen(port); } if (require.main === module) { - main(process.argv[2] || 'client'); + main(process.argv[2] || 'client', 3000); }