Use config when starting development server (#9410)

* Use config when starting development server

* import nconf setup from website

* Add comment explaining choice

* Fix lint issues
This commit is contained in:
MathWhiz
2017-11-27 20:38:27 -06:00
committed by Sabe Jones
parent dd05a8d608
commit 200cd66d66
3 changed files with 19 additions and 16 deletions

View File

@@ -3,6 +3,14 @@ const path = require('path');
const staticAssetsDirectory = './website/static/.'; // The folder where static files (not processed) live const staticAssetsDirectory = './website/static/.'; // The folder where static files (not processed) live
const prodEnv = require('./prod.env'); const prodEnv = require('./prod.env');
const devEnv = require('./dev.env'); const devEnv = require('./dev.env');
const nconf = require('nconf');
const setupNconf = require('../../website/server/libs/setupNconf');
let configFile = path.join(path.resolve(__dirname, '../../config.json'));
setupNconf(configFile);
const DEV_BASE_URL = nconf.get('BASE_URL');
module.exports = { module.exports = {
build: { build: {
@@ -33,25 +41,25 @@ module.exports = {
assetsPublicPath: '/', assetsPublicPath: '/',
staticAssetsDirectory, staticAssetsDirectory,
proxyTable: { proxyTable: {
// proxy all requests starting with /api/v3 to localhost:3000 // proxy all requests starting with /api/v3 to IP:PORT as specified in the top-level config
'/api/v3': { '/api/v3': {
target: 'http://localhost:3000', target: DEV_BASE_URL,
changeOrigin: true, changeOrigin: true,
}, },
'/stripe': { '/stripe': {
target: 'http://localhost:3000', target: DEV_BASE_URL,
changeOrigin: true, changeOrigin: true,
}, },
'/amazon': { '/amazon': {
target: 'http://localhost:3000', target: DEV_BASE_URL,
changeOrigin: true, changeOrigin: true,
}, },
'/paypal': { '/paypal': {
target: 'http://localhost:3000', target: DEV_BASE_URL,
changeOrigin: true, changeOrigin: true,
}, },
'/logout': { '/logout': {
target: 'http://localhost:3000', target: DEV_BASE_URL,
changeOrigin: true, changeOrigin: true,
}, },
}, },

View File

@@ -1,17 +1,11 @@
const nconf = require('nconf'); const nconf = require('nconf');
const { join, resolve } = require('path'); const { join, resolve } = require('path');
const setupNconf = require('../../website/server/libs/setupNconf');
const PATH_TO_CONFIG = join(resolve(__dirname, '../../config.json')); const PATH_TO_CONFIG = join(resolve(__dirname, '../../config.json'));
let configFile = PATH_TO_CONFIG; let configFile = PATH_TO_CONFIG;
nconf setupNconf(configFile);
.argv()
.env()
.file('user', configFile);
nconf.set('IS_PROD', nconf.get('NODE_ENV') === 'production');
nconf.set('IS_DEV', nconf.get('NODE_ENV') === 'development');
nconf.set('IS_TEST', nconf.get('NODE_ENV') === 'test');
// @TODO: Check if we can import from client. Items like admin emails can be imported // @TODO: Check if we can import from client. Items like admin emails can be imported
// and that should be prefered // and that should be prefered

View File

@@ -1,5 +1,6 @@
import nconf from 'nconf'; // require allows import from webpack
import { join, resolve } from 'path'; const nconf = require('nconf');
const { join, resolve } = require('path');
const PATH_TO_CONFIG = join(resolve(__dirname, '../../../config.json')); const PATH_TO_CONFIG = join(resolve(__dirname, '../../../config.json'));