|
1 | | -import { createStore, applyMiddleware, compose } from 'redux'; |
2 | | -import { reduxReactRouter } from 'redux-router'; |
3 | | -import { devTools } from 'redux-devtools'; |
4 | | -import createHistory from 'history/lib/createBrowserHistory'; |
5 | | -import routes from '../routes'; |
6 | | -import thunk from 'redux-thunk'; |
7 | | -import api from '../middleware/api'; |
8 | | -import createLogger from 'redux-logger'; |
9 | | -import rootReducer from '../reducers'; |
10 | | - |
11 | | -const finalCreateStore = compose( |
12 | | - applyMiddleware(thunk, api), |
13 | | - reduxReactRouter({ routes, createHistory }), |
14 | | - applyMiddleware(createLogger()), |
15 | | - devTools() |
16 | | -)(createStore); |
17 | | - |
18 | | -export default function configureStore(initialState) { |
19 | | - const store = finalCreateStore(rootReducer, initialState); |
20 | | - |
21 | | - if (module.hot) { |
22 | | - // Enable Webpack hot module replacement for reducers |
23 | | - module.hot.accept('../reducers', () => { |
24 | | - const nextRootReducer = require('../reducers'); |
25 | | - store.replaceReducer(nextRootReducer); |
26 | | - }); |
27 | | - } |
28 | | - |
29 | | - return store; |
| 1 | +if (process.env.NODE_ENV === 'production') { |
| 2 | + module.exports = require('./configureStore.prod'); |
| 3 | +} else { |
| 4 | + module.exports = require('./configureStore.dev'); |
30 | 5 | } |
0 commit comments