From 3d5bf1075be995330a18aa5a148eaf1b427d0564 Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Wed, 22 Apr 2015 08:56:32 -0400 Subject: [PATCH] use express instead of gulp-webserver. Fixes #780 and #773. --- gulpfile.js | 14 +++++--------- package.json | 1 - test/browser/run-in-phantom.js | 8 +------- test/browser/server.js | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 test/browser/server.js diff --git a/gulpfile.js b/gulpfile.js index f8bfaa688..8f43ad9e3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,4 @@ var path = require('path'); -var webserver = require('gulp-webserver'); var _ = require('underscore'); var gulp = require('gulp'); var gulpif = require('gulp-if'); @@ -31,6 +30,7 @@ require('node-jsx').install(); var IndexFileStream = require('./lib/gulp-index-file-stream'); var webpackConfig = require('./webpack.config'); var travis = require('./lib/travis'); +var server = require('./test/browser/server'); var BUILD_TASKS = [ 'beautify', @@ -253,14 +253,10 @@ gulp.task('watch', _.without(BUILD_TASKS, 'webpack'), function() { process.exit(0); }); - gulp.src('dist') - .pipe(webserver({ - livereload: { - enable: true - }, - host: '0.0.0.0', - port: 8008 - })); + server.create().listen(8008, function() { + gutil.log('Development server listening at ' + + gutil.colors.green.bold('http://localhost:8008') + '.'); + }); }); gulp.task('travis-after-success', function(cb) { diff --git a/package.json b/package.json index 4447304ac..143319b59 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "gulp-sourcemaps": "^1.5.0", "gulp-util": "^3.0.4", "gulp-webpack": "^1.2.0", - "gulp-webserver": "^0.9.0", "imports-loader": "^0.6.3", "json-loader": "^0.5.1", "jsx-loader": "^0.12.2", diff --git a/test/browser/run-in-phantom.js b/test/browser/run-in-phantom.js index 52dec7e6d..029db7b71 100644 --- a/test/browser/run-in-phantom.js +++ b/test/browser/run-in-phantom.js @@ -1,15 +1,9 @@ -var http = require('http'); var path = require('path'); var chalk = require('chalk'); -var express = require('express'); var ROOT_DIR = path.normalize(path.join(__dirname, '..', '..')); -var app = express(); - -var server = http.createServer(app); - -app.use(express.static(path.join(ROOT_DIR, 'dist'))); +var server = require('./server').create(); server.listen(0, function() { var baseURL = 'http://localhost:' + server.address().port; diff --git a/test/browser/server.js b/test/browser/server.js new file mode 100644 index 000000000..06b11f436 --- /dev/null +++ b/test/browser/server.js @@ -0,0 +1,14 @@ +var http = require('http'); +var path = require('path'); +var express = require('express'); + +var ROOT_DIR = path.normalize(path.join(__dirname, '..', '..', 'dist')); + +exports.create = function create() { + var app = express(); + var server = http.createServer(app); + + app.use(express.static(ROOT_DIR)); + + return server; +};