UNPKG

brat-frontend-editor

Version:
44 lines (38 loc) 1.24 kB
import { applyMiddleware, compose, createStore } from 'redux' import thunk from 'redux-thunk' import makeRootReducer from './reducers' export default (initialState = {}) => { // ====================================================== // Middleware Configuration // ====================================================== const middleware = [thunk] // ====================================================== // Store Enhancers // ====================================================== const enhancers = [] if (__DEV__) { const devToolsExtension = window.devToolsExtension if (typeof devToolsExtension === 'function') { enhancers.push(devToolsExtension()) } } // ====================================================== // Store Instantiation and HMR Setup // ====================================================== const store = createStore( makeRootReducer(), initialState, compose( applyMiddleware(...middleware), ...enhancers ) ) store.asyncReducers = {} if (module.hot) { module.hot.accept('./reducers', () => { const reducers = require('./reducers').default store.replaceReducer(reducers(store.asyncReducers)) }) } return store }