From 17ef63b171db928501bb298f3ff4c2b4a721c819 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 24 Apr 2017 14:53:23 -0700 Subject: [PATCH] Only setup the integration with Redux devtools if dev sets env var --- CONTRIBUTING.md | 6 ++++-- packages/gatsby/lib/redux/index.js | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e5f0cf1aa08aa..86dbf9e1e9f57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,8 +48,10 @@ devtools extension for debugging Gatsby. To use this, first install [redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension) -in your browser. Then in your Gatsby repo, run `npm run remotedev`. Then -in your site directory run `gatsby develop`. +in your browser. Then in your Gatsby repo, run `npm run remotedev`. Then in +your site directory run `REDUX_DEVTOOLS=true gatsby develop`. Depending on +your operating system and shell, you may need to modify how you set the +`REDUX_DEVTOOLS` environment variable. At this point, your site will be sending Redux actions and state to the remote server. diff --git a/packages/gatsby/lib/redux/index.js b/packages/gatsby/lib/redux/index.js index 0567cc628e00a..b916d1842fa53 100644 --- a/packages/gatsby/lib/redux/index.js +++ b/packages/gatsby/lib/redux/index.js @@ -17,25 +17,24 @@ try { // ignore errors. } -const sitePackageJSON = require(`${process.cwd()}/package.json`) -const composeEnhancers = composeWithDevTools({ - realtime: true, - port: 19999, - name: sitePackageJSON.name, -}) - let store -// Don't try connecting to devtools server if testing or building. -if (process.env.NODE_ENV === `test` || process.env.NODE_ENV === `production`) { +// Only setup the Redux devtools if explicitly enabled. +if (process.env.REDUX_DEVTOOLS === `true`) { + const sitePackageJSON = require(`${process.cwd()}/package.json`) + const composeEnhancers = composeWithDevTools({ + realtime: true, + port: 19999, + name: sitePackageJSON.name, + }) store = Redux.createStore( Redux.combineReducers({ ...reducers }), - initialState + initialState, + composeEnhancers(Redux.applyMiddleware()) ) } else { store = Redux.createStore( Redux.combineReducers({ ...reducers }), - initialState, - composeEnhancers(Redux.applyMiddleware()) + initialState ) }