Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only setup the integration with Redux devtools if dev sets env var #851

Merged
merged 1 commit into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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