UNPKG

2.06 kBJavaScriptView Raw
1import reducer from './reducers'
2import routes from './routes'
3import thunk from 'redux-thunk'
4import Helmet from 'react-helmet'
5
6//Have any top level css or images? Import them here
7//import './index.css';
8
9const config = {
10 polyfills: 'default,fetch,Symbol,Symbol.iterator,Array.prototype.find',
11 requestExtendedUserInfo: false,
12 redux: {
13 reducer: reducer,
14 //initialState: {}
15 middleware: [thunk]
16 //enhancers: []
17 //parseServerState: (serverState) => {
18 // If you have any special parsing you need to do of the plain
19 // plain JSON Object coming from the server you can do that here.
20 // Useful for example for immutable libraries like Immutable.js
21 //}
22 },
23 router: {
24 routes: routes
25 },
26 head: {
27 helmet: Helmet
28 },
29 init: env => {
30 //you can do any custom initialization.
31 //You have available the following objects on env:
32 //req (request), userInfo, store, config & history
33 }
34}
35
36export default config
37
38/*
39You are also able supply a function that creates a configuration file. The
40single argument is the environment the code is running in: 'CLIENT' or 'SERVER'
41*/
42
43/*
44import thunk from 'redux-thunk'
45import { browserHistory } from 'react-router';
46import { routerMiddleware } from 'react-router-redux';
47import { persistStore, autoRehydrate } from 'redux-persist';
48import localForage from 'localforage';
49import rootReducer from './reducer/index';
50import routes from './framework/Routes'
51
52const config = (render_env) => {
53 const logger = createLogger();
54 const router = routerMiddleware(browserHistory);
55
56 return {
57 redux: {
58 reducer: rootReducer,
59 middleware: [thunk, router],
60 enhancers: render_env === 'CLIENT' && [autoRehydrate()]
61 },
62 router: {
63 routes: routes
64 },
65 head: {
66 helmet: Helmet
67 }
68 init: (env) => {
69 if(render_env === 'CLIENT') {
70 const onComplete = () => { console.log("Rehydrate is complete!"); };
71 persistStore(env.store, { storage: localForage }, onComplete);
72 }
73 }
74 };
75}
76
77
78
79export default config
80*/