1

Fixing autoreload

This commit is contained in:
Alex Yatskov 2014-10-03 11:33:06 +09:00
parent dfd4df9da2
commit fe1a3de4bf
2 changed files with 21 additions and 11 deletions

View File

@ -71,32 +71,42 @@ gulp.task('scripts', function() {
gulp.task('styles', function() { gulp.task('styles', function() {
var styles = getBowerFiles('.css').concat(['client/styles/*.css']); 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')); 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 sources = gulp.src(getBowerFiles('.css').concat(getBowerFiles('.js')).concat(['client/scripts/*.js', 'client/styles/*.css']), {read: false});
var target = 'client/html/index.html'; var target = 'client/html/index.html';
var options = {addRootSlash: false, ignorePath: 'client'}; var options = {addRootSlash: false, ignorePath: 'client'};
return gulp.src(target).pipe(inject(sources, options)).pipe(gulp.dest('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 sources = gulp.src(['client/dist/*.js', 'client/dist/*.css'], {read: false});
var options = {addRootSlash: false, ignorePath: 'client/dist'}; var options = {addRootSlash: false, ignorePath: 'client/dist'};
var target = 'client/html/index.html'; var target = 'client/html/index.html';
return gulp.src(target).pipe(inject(sources, options)).pipe(minifyHtml()).pipe(gulp.dest('client/dist')); return gulp.src(target).pipe(inject(sources, options)).pipe(minifyHtml()).pipe(gulp.dest('client/dist'));
}); });
gulp.task('dev', ['lint', 'html_dev'], function() { gulp.task('dev', ['html_dev'], function() {
var options = {script: 'server/server.js', ext: 'js', port: 8000, args: ['client']}; var options = {
return nodemon(options).on('change', ['lint']); 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() { gulp.task('dist', ['html_dist'], function() {
var options = {script: 'server/server.js', ext: 'js', port: 8000, args: ['client/dist']}; var options = {
return nodemon(options).on('change', ['lint']); 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']); gulp.task('default', ['dev']);

View File

@ -33,7 +33,7 @@ var express = require('express');
var path = require('path'); var path = require('path');
var search = require('./search.js'); var search = require('./search.js');
function main(staticFiles) { function main(staticFiles, port) {
var app = express(); var app = express();
search.loadDb({ search.loadDb({
@ -67,9 +67,9 @@ function main(staticFiles) {
}); });
app.use(express.static(path.join(__dirname, '..', staticFiles))); app.use(express.static(path.join(__dirname, '..', staticFiles)));
app.listen(3000); app.listen(port);
} }
if (require.main === module) { if (require.main === module) {
main(process.argv[2] || 'client'); main(process.argv[2] || 'client', 3000);
} }