-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (37 loc) · 1.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { createStore, compose, applyMiddleware } = require('redux')
const { install: installReduxLoop } = require('redux-loop')
const createLogger = require('redux-logger')
const React = require('react')
const ReactDOM = require('react-dom')
const { Provider: ReduxProvider } = require('react-redux')
const { Router, createMemoryHistory } = require('react-router')
const { routerMiddleware, syncHistoryWithStore } = require('react-router-redux')
const { createRenderer } = require('fela')
const { Provider: FelaProvider } = require('react-fela')
const insertCss = require('insert-css')
insertCss(require('fs').readFileSync('styles/file-drop.css', 'utf-8'))
const config = require('./config')
const routes = require('./routes')
const reducer = require('./reducer')(config)
const memoryHistory = createMemoryHistory()
let middleware = [routerMiddleware(memoryHistory)]
if (process.env.NODE_ENV === 'development') {
middleware = [...middleware, createLogger()]
}
const enhancer = compose(
installReduxLoop(),
applyMiddleware(...middleware)
)
const store = createStore(reducer, undefined, enhancer)
const history = syncHistoryWithStore(memoryHistory, store)
const renderer = createRenderer()
ReactDOM.render(
<ReduxProvider store={store}>
<FelaProvider renderer={renderer}>
<Router history={history}>
{ routes }
</Router>
</FelaProvider>
</ReduxProvider>,
document.getElementById('main')
)