From 17d4a6abe68773ee18f964b987c8952fefa6ede3 Mon Sep 17 00:00:00 2001 From: Kayden Althen Date: Fri, 8 Feb 2019 14:18:48 -0600 Subject: [PATCH] refactor env vars in webpack.config and pwadevserver files --- docker/.env.docker | 1 - .../pwa-buildpack/src/WebpackTools/PWADevServer.js | 10 ++++++---- packages/venia-concept/webpack.config.js | 4 +--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docker/.env.docker b/docker/.env.docker index 90e96158c0..d3de2f52da 100644 --- a/docker/.env.docker +++ b/docker/.env.docker @@ -15,4 +15,3 @@ UPWARD_JS_UPWARD_PATH=venia-upward.yml UPWARD_JS_BIND_LOCAL=1 UPWARD_JS_LOG_URL=1 BRAINTREE_TOKEN=sandbox_8yrzsvtm_s2bg8fs563crhqzk -DOCKER_CONFIG=1 diff --git a/packages/pwa-buildpack/src/WebpackTools/PWADevServer.js b/packages/pwa-buildpack/src/WebpackTools/PWADevServer.js index 2ba9d48cc3..4494cddf87 100644 --- a/packages/pwa-buildpack/src/WebpackTools/PWADevServer.js +++ b/packages/pwa-buildpack/src/WebpackTools/PWADevServer.js @@ -1,3 +1,4 @@ +require('dotenv').config(); const debug = require('../util/debug').makeFileLogger(__filename); const debugErrorMiddleware = require('debug-error-middleware').express; const { @@ -44,8 +45,10 @@ const PWADevServer = { contentBase: false, // UpwardPlugin serves static files compress: true, hot: true, - host: config.host || '0.0.0.0', - port: config.port || (await portscanner.findAPortNotInUse(10000)), + host: process.env.PWA_STUDIO_HOST_DEVELOPMENT || '0.0.0.0', + port: + process.env.PWA_STUDIO_PORTS_DEVELOPMENT || + (await portscanner.findAPortNotInUse(10000)), stats: { all: !process.env.NODE_DEBUG ? false : undefined, builtAt: true, @@ -59,8 +62,7 @@ const PWADevServer = { }, after(app, server) { app.use(debugErrorMiddleware()); - require('dotenv').config(); - let publicPath = process.env.DOCKER_CONFIG + let publicPath = process.env.PWA_STUDIO_PUBLIC_PATH ? 'https://' + process.env.PWA_STUDIO_PUBLIC_PATH : devServerConfig.publicPath; let readyNotice = chalk.green( diff --git a/packages/venia-concept/webpack.config.js b/packages/venia-concept/webpack.config.js index 9863d3b344..6cb66355e0 100644 --- a/packages/venia-concept/webpack.config.js +++ b/packages/venia-concept/webpack.config.js @@ -171,9 +171,7 @@ module.exports = async function(env) { validEnv.PWA_STUDIO_PUBLIC_PATH || config.output.publicPath, graphqlPlayground: { queryDirs: [path.resolve(themePaths.src, 'queries')] - }, - port: validEnv.PWA_STUDIO_PORTS_DEVELOPMENT, - host: validEnv.PWA_STUDIO_HOST_DEVELOPMENT + } }; const provideHost = !!validEnv.MAGENTO_BUILDPACK_PROVIDE_SECURE_HOST; if (provideHost) {