|
|
|
@ -2,6 +2,8 @@ import promise from 'redux-promise-middleware';
|
|
|
|
|
import { createLogger } from 'redux-logger';
|
|
|
|
|
import { configureStore } from '@reduxjs/toolkit';
|
|
|
|
|
import { reducer as allReducers } from './reducer';
|
|
|
|
|
import { persistReducer } from "redux-persist";
|
|
|
|
|
import storage from 'redux-persist/lib/storage';
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
const env = window.getEnvironment();
|
|
|
|
@ -22,13 +24,23 @@ const logger = createLogger({
|
|
|
|
|
logger: directConsole,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const persistConfig = {
|
|
|
|
|
key: 'root',
|
|
|
|
|
storage,
|
|
|
|
|
whitelist: ['userConfig']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const persistedReducer = persistReducer(persistConfig, allReducers);
|
|
|
|
|
|
|
|
|
|
// Exclude logger if we're in production mode
|
|
|
|
|
const disableLogging = env === 'production' || true; // ALWAYS TURNED OFF
|
|
|
|
|
// const middlewareList = disableLogging ? [promise, thunk] : [promise, logger, thunk ];
|
|
|
|
|
const middlewareList = disableLogging ? [promise] : [promise, logger];
|
|
|
|
|
|
|
|
|
|
export const createStore = (initialState: any) =>
|
|
|
|
|
configureStore({
|
|
|
|
|
reducer: allReducers,
|
|
|
|
|
// reducer: allReducers,
|
|
|
|
|
reducer: persistedReducer,
|
|
|
|
|
preloadedState: initialState,
|
|
|
|
|
middleware: (getDefaultMiddleware: any) => getDefaultMiddleware().concat(middlewareList),
|
|
|
|
|
});
|
|
|
|
|