Skip to content

Commit

Permalink
feat(core): Remove DevTools from Production (react-boilerplate#1175)
Browse files Browse the repository at this point in the history
* Envify DevTools

* Updated templates for Devtools
  • Loading branch information
ansumanshah authored and mxstbr committed Nov 3, 2016
1 parent 1975097 commit 42cc8d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export default function configureStore(initialState = {}, history) {

// If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
/* eslint-enable */

const store = createStore(
Expand Down
13 changes: 10 additions & 3 deletions internals/templates/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import createSagaMiddleware from 'redux-saga';
import createReducer from './reducers';

const sagaMiddleware = createSagaMiddleware();
const devtools = window.devToolsExtension || (() => (noop) => noop);

export default function configureStore(initialState = {}, history) {
// Create the store with two middlewares
Expand All @@ -22,13 +21,21 @@ export default function configureStore(initialState = {}, history) {

const enhancers = [
applyMiddleware(...middlewares),
devtools(),
];

// If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */
const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
/* eslint-enable */

const store = createStore(
createReducer(),
fromJS(initialState),
compose(...enhancers)
composeEnhancers(...enhancers)
);

// Extensions
Expand Down

0 comments on commit 42cc8d8

Please sign in to comment.