From a481e732d23df9fca05a45c5875d7289257ffc8e Mon Sep 17 00:00:00 2001 From: Andrei Kashcha Date: Wed, 30 Mar 2016 22:36:04 -0700 Subject: [PATCH] Configurable dev server port Allow it to come from environment variables. --- template/build/dev-server.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/template/build/dev-server.js b/template/build/dev-server.js index 167c64d0e7..3e5179afaf 100644 --- a/template/build/dev-server.js +++ b/template/build/dev-server.js @@ -3,6 +3,9 @@ var webpack = require('webpack') var config = require('./webpack.dev.conf') var proxyMiddleware = require('http-proxy-middleware') +// default port where dev server listens for incoming traffic +var port = process.env.PORT || 8080 + var app = express() var compiler = webpack(config) @@ -57,10 +60,10 @@ app.use(hotMiddleware) // serve pure static assets app.use('/static', express.static('./static')) -module.exports = app.listen(8080, function (err) { +module.exports = app.listen(port, function (err) { if (err) { console.log(err) return } - console.log('Listening at http://localhost:8080\n') + console.log('Listening at http://localhost:' + port + '\n') })