Add runtime environment variable

Add a variable that can be used to differentiate between dev, staging
and production environments.
This commit is contained in:
Hannu Lyytikainen 2017-11-16 18:31:31 +02:00
parent 69480bf823
commit ce07746bee
4 changed files with 7 additions and 7 deletions

View file

@ -33,7 +33,8 @@ const log = require('./log');
const { sitemapStructure } = require('./sitemap');
const buildPath = path.resolve(__dirname, '..', 'build');
const dev = process.env.NODE_ENV !== 'production';
const env = process.env.REACT_APP_ENV;
const dev = env !== 'staging' && env !== 'production';
const PORT = process.env.PORT || 4000;
const CLIENT_ID =
process.env.REACT_APP_SHARETRIBE_SDK_CLIENT_ID || '08ec69f6-d37e-414d-83eb-324e94afddf0';

View file

@ -6,7 +6,7 @@
const Raven = require('raven');
const ENV = process.env.NODE_ENV;
const ENV = process.env.REACT_APP_ENV;
const SENTRY_DSN = process.env.SERVER_SENTRY_DSN;
/**

View file

@ -1,5 +1,5 @@
const env = process.env.NODE_ENV;
const dev = env !== 'production';
const env = process.env.REACT_APP_ENV;
const dev = env !== 'staging' && env !== 'production';
// To pass environment variables to the client app in the build
// script, react-scripts (and the sharetribe-scripts fork of

View file

@ -3,6 +3,7 @@ import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import createReducer from './reducers';
import * as analytics from './analytics/analytics';
import config from './config';
/**
* Create a new store with the given initial state. Adds Redux
@ -13,9 +14,7 @@ export default function configureStore(initialState = {}, sdk = null, analyticsH
// Enable Redux Devtools in client side dev mode.
const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
config.dev && typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: compose;