When I run gulp without the node
task, it works fine and processes client file as expected, If I run gulp node
it processes server file as expected. However if I run both gulp
it processes both client and server file as expected, however, it won't let me quit by pressing 'Ctrl + C' (Tried it on windows 10 & Mac El Capitan). Is there something I'm doing wrong here?
'use strict';
var gulp = require('gulp');
var connect = require('gulp-connect');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var nodemon = require('gulp-nodemon');
var config = {
port: 9005,
devBaseUrl: 'http://localhost',
paths: {
html: './src/*.html',
dist: './dist',
js: './src/**/*.js',
images: './src/images/*',
mainJs: './src/main.js',
css: [
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/bootstrap/dist/css/bootstrap-theme.min.css'
]
}
};
gulp.task('connect', function () {
connect.server({
root: ['dist'],
port: config.port,
base: config.devBaseUrl,
livereload: true
});
});
gulp.task('html', function () {
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist))
});
gulp.task('js', function () {
browserify(config.paths.mainJs)
.bundle()
.on('error', console.error.bind(console))
.pipe(source('bundle.js'))
.pipe(gulp.dest(config.paths.dist + '/scripts'))
.pipe(connect.reload())
});
gulp.task('node', function () {
nodemon({
script: 'server/index.js',
ext: 'js',
env: {
PORT: 8000
},
ignore: ['node_modules/**','src/**','dist/**']
})
.on('restart', function () {
console.log('Restarting node server...');
})
});
gulp.task('watch', function () {
gulp.watch(config.paths.js, ['js']);
});
gulp.task('default', ['html', 'js', 'connect', 'node', 'watch']);