Skip to content

Commit

Permalink
Only setup the integration with Redux devtools if dev sets env var
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Apr 24, 2017
1 parent 3ca0478 commit 17ef63b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
23 changes: 11 additions & 12 deletions packages/gatsby/lib/redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down

0 comments on commit 17ef63b

Please sign in to comment.