configureStore.ts 1.0 KB

1234567891011121314151617181920212223242526272829
  1. import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
  2. import thunk from 'redux-thunk';
  3. import { createLogger } from 'redux-logger';
  4. import sharedReducers from 'app/core/reducers';
  5. import alertingReducers from 'app/features/alerting/state/reducers';
  6. import teamsReducers from 'app/features/teams/state/reducers';
  7. import foldersReducers from 'app/features/folders/state/reducers';
  8. import dashboardReducers from 'app/features/dashboard/state/reducers';
  9. const rootReducer = combineReducers({
  10. ...sharedReducers,
  11. ...alertingReducers,
  12. ...teamsReducers,
  13. ...foldersReducers,
  14. ...dashboardReducers,
  15. });
  16. export let store;
  17. export function configureStore() {
  18. const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  19. if (process.env.NODE_ENV !== 'production') {
  20. // DEV builds we had the logger middleware
  21. store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk, createLogger())));
  22. } else {
  23. store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk)));
  24. }
  25. }