p5.js-web-editor/client/store.js
2016-06-22 18:36:04 -04:00

32 lines
No EOL
901 B
JavaScript

import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import DevTools from './modules/App/components/DevTools'
import rootReducer from './reducers'
export default function configureStore(initialState) {
const enhancers = [
applyMiddleware(thunk),
];
if (process.env.CLIENT && process.env.NODE_ENV === 'development') {
// Enable DevTools only when rendering on client and during development.
enhancers.push(window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument());
}
const store = createStore(
rootReducer,
initialState,
compose(...enhancers)
)
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
const nextRootReducer = require('./reducers').default
store.replaceReducer(nextRootReducer)
})
}
return store
}