From dec2db2ee96ffcff218a464d750012876dcd4533 Mon Sep 17 00:00:00 2001 From: Makemek Date: Wed, 8 Feb 2017 17:59:56 +0700 Subject: [PATCH] configurable port for app and development application port: PORT port for development: PORT_DEV PORT_DEV will take effect when run gulp browser-sync. Meaning that PORT_DEV will take effect when run `npm run dev` too. --- .env.template | 2 ++ gulpfile.js | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.env.template b/.env.template index ba384d0..42b8226 100644 --- a/.env.template +++ b/.env.template @@ -2,6 +2,8 @@ "SESSION_SECRET": "DEFAULT", "LOGGER_SILENT": "false", "LOGGER_LEVEL": "info", + "PORT": 5000, + "PORT_DEV": 3000, "KANCOLLE_SERVER_MASTER": "http://203.104.209.7", "KANCOLLE_SERVER_1" : "http://203.104.209.71", diff --git a/gulpfile.js b/gulpfile.js index 9693909..f1fc817 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,10 @@ 'use strict' +const appPort = process.env.PORT +const devPort = process.env.PORT_DEV +const css = 'src/views/*.css' +const htmlTemplate = 'src/views/**/*.hbs' + const gulp = require('gulp') const postcss = require('gulp-postcss') const autoprefixer = require('autoprefixer') @@ -8,10 +13,6 @@ const rename = require('gulp-rename') const bs = require('browser-sync').create() const nodemon = require('gulp-nodemon') -const devPort = 8080 -const css = 'src/views/*.css' -const htmlTemplate = 'src/views/**/*.hbs' - gulp.task('build', ['build:css']) gulp.task('build:css', () => { @@ -28,7 +29,7 @@ gulp.task('nodemon', done => { return nodemon({ script: 'bin/www', ignore: ['gulpfile.js', 'node_modules/', 'src/views/'], - env: {PORT: devPort} + env: {PORT: appPort} }) .on('start', () => { if(!start) { @@ -40,7 +41,8 @@ gulp.task('nodemon', done => { gulp.task('browser-sync', ['nodemon'], () => { bs.init({ - proxy: `localhost:${devPort}`, + proxy: `localhost:${appPort}`, + port: devPort, open: false })