mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-06-13 01:23:15 +03:00
* Use rollup for d3tooltip * Use rollup for map2tree * Set moduleResolution * Use rollup for d3-state-visualizer * Use rollup for react-base16-styling * Use rollup for react-dock * Use rollup for react-json-tree * Use rollup for redux-devtools * Use rollup for redux-devtools-intrument * Use rollup for redux-devtools-chart-monitor * Update export * Use rollup for redux-devtools-dock-monitor * Use rollup for redux-devtools-inspector-monitor * Fix inspector demo * Fix invalid eslint config * Use rollup for inspector-monitor-test-tab * Use rollup for inspector-monitor-trace-tab * Use rollup for redux-devtools-log-monitor * Use rollup for redux-devtools-remote * Use rollup in redux-devtools-rtk-query-monitor * Use rollup for redux-devtools-serialize * Fix redux-devtools examples * Use rollup for redux-devtools-slider-monitor * Fix slider examples * Use rollup for redux-devtools-ui * Use rollup for redux-devtools-utils * Use rollup for redux-devtools-extension * Use rollup for redux-devtools-app * Fix Webpack app build * Fix extension build * Turn on minimization * Update CLI
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { createStore, compose, applyMiddleware, Reducer, Store } from 'redux';
|
|
import localForage from 'localforage';
|
|
import { persistReducer, persistStore } from 'redux-persist';
|
|
import { api } from '../middlewares/api';
|
|
import { exportStateMiddleware } from '../middlewares/exportState';
|
|
import { rootReducer, StoreState } from '../reducers';
|
|
import { StoreAction } from '../actions';
|
|
|
|
const persistConfig = {
|
|
key: 'redux-devtools',
|
|
blacklist: ['instances', 'socket'],
|
|
storage: localForage,
|
|
};
|
|
|
|
const persistedReducer: Reducer<StoreState, StoreAction> = persistReducer(
|
|
persistConfig,
|
|
rootReducer
|
|
) as any;
|
|
|
|
export default function configureStore(
|
|
callback: (store: Store<StoreState, StoreAction>) => void
|
|
) {
|
|
let composeEnhancers = compose;
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
if (
|
|
(
|
|
window as unknown as {
|
|
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
|
|
}
|
|
).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
) {
|
|
composeEnhancers = (
|
|
window as unknown as {
|
|
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__: typeof compose;
|
|
}
|
|
).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
|
}
|
|
if (module.hot) {
|
|
// Enable Webpack hot module replacement for reducers
|
|
module.hot.accept('../reducers', () => {
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const nextReducer = require('../reducers'); // eslint-disable-line global-require
|
|
store.replaceReducer(nextReducer as Reducer<StoreState, StoreAction>);
|
|
});
|
|
}
|
|
}
|
|
|
|
const store = createStore(
|
|
persistedReducer,
|
|
composeEnhancers(applyMiddleware(exportStateMiddleware, api))
|
|
);
|
|
const persistor = persistStore(store, null, () => {
|
|
callback(store);
|
|
});
|
|
return { store, persistor };
|
|
}
|