git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 0a19ff71e90207bdc5e6b22d5470c11617f9f7b0

Files: 0a19ff71e90207bdc5e6b22d5470c11617f9f7b0 / app / store.js

1310 bytesRaw
1const { createStore, compose, applyMiddleware } = require('redux')
2const thunk = require('redux-thunk')
3const logger = require('redux-logger')
4const { reduxReactRouter, routerStateReducer, ReduxRouter } = require('redux-router')
5const { createHistory } = require('history')
6
7const rootReducer = require('app/reducers')
8const routes = require('routes')
9
10let storesEnhancers = []
11let middleware = []
12
13middleware.push(thunk)
14
15if (process.env.NODE_ENV === 'development') {
16 const { persistState } = require('redux-devtools')
17
18 middleware.push(logger())
19}
20
21storesEnhancers.push(
22 applyMiddleware(middleware)
23)
24
25if (process.env.NODE_ENV === 'development') {
26 storesEnhancers.push(DevTools.instrument())
27 storesEnhancers.push(persistState(
28 window.location.href.match(
29 /[?&]debug_session=([^&]+)\b/
30 )
31 ))
32}
33
34storesEnhancers.push(
35 reduxReactRouter({
36 routes, createHistory
37 })
38)
39
40const finalCreateStore = compose(
41 ...storesEnhancers
42)(createStore)
43
44function configureStore(initialState) {
45 const store = finalCreateStore(rootReducer, initialState)
46
47 if (process.env.NODE_ENV === 'development') {
48 if (module.hot) {
49 module.hot.accept('app/reducers', () =>
50 store.replaceReducer(require('app/reducers'))
51 )
52 }
53 }
54
55 return store
56}
57
58module.exports = configureStore
59
60

Built with git-ssb-web