diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 8d2a6e25fa..78bd8275af 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -169,9 +169,6 @@ exports.onCreateWebpackConfig = ({ stage, plugins, actions }) => { process.env.HOME_PATH || 'http://localhost:3000' ), STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PUBLIC_KEY || ''), - ENVIRONMENT: JSON.stringify( - process.env.FREECODECAMP_NODE_ENV || 'development' - ), PAYPAL_SUPPORTERS: JSON.stringify(process.env.PAYPAL_SUPPORTERS || 404) }) ]; diff --git a/client/src/redux/createStore.js b/client/src/redux/createStore.js index 9c824d3c5e..608404b582 100644 --- a/client/src/redux/createStore.js +++ b/client/src/redux/createStore.js @@ -9,6 +9,8 @@ import rootReducer from './rootReducer'; import rootSaga from './rootSaga'; import { isBrowser } from '../../utils'; +import { environment } from '../../../config/env.json'; + const clientSide = isBrowser(); const sagaMiddleware = createSagaMiddleware({ @@ -29,10 +31,18 @@ const composeEnhancers = composeWithDevTools({ }); export const createStore = () => { - const store = reduxCreateStore( - rootReducer, - composeEnhancers(applyMiddleware(sagaMiddleware, epicMiddleware)) - ); + let store; + if (environment === 'production') { + store = reduxCreateStore( + rootReducer, + applyMiddleware(sagaMiddleware, epicMiddleware) + ); + } else { + store = reduxCreateStore( + rootReducer, + composeEnhancers(applyMiddleware(sagaMiddleware, epicMiddleware)) + ); + } sagaMiddleware.run(rootSaga); epicMiddleware.run(rootEpic); if (module.hot) { diff --git a/config/env.js b/config/env.js index 5c5b5cd1ab..1144545613 100644 --- a/config/env.js +++ b/config/env.js @@ -37,6 +37,7 @@ const locations = { module.exports = Object.assign(locations, { locale, deploymentEnv, + environment: process.env.FREECODECAMP_NODE_ENV || 'development', stripePublicKey: !stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard' ? null