32 lines
949 B
JavaScript
32 lines
949 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; // eslint-disable-line global-require
|
|
store.replaceReducer(nextRootReducer);
|
|
});
|
|
}
|
|
|
|
return store;
|
|
}
|
|
|