1.0.1 โ€ข Published 2 years ago

vite-plugin-redux-hmr v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

โšก Vite Plugin Redux HMR (Hot Module Reloading)

๐Ÿ“— Description

Implements Hot Module Reloading (HMR) for your Redux library when in development. NOTE: HMR only works when there are no circular dependencies between your files, otherwise Vite will fallback to full reload.

๐Ÿงช Important

  1. In order for this plugin to work you need to have your reducers exported as a default export in a seprate reducers file.
  2. The reducers file needs to be imported in your main redux index file (the file that calls configureStore() or createStore() and defines your store variable).

๐Ÿš€ Install

npm i vite-plugin-redux-hmr -D

# yarn
yarn add vite-plugin-redux-hmr -D

# pnpm
pnpm add vite-plugin-redux-hmr -D

๐Ÿง‘โ€๐Ÿ’ป Usage (vite.config.ts / vite.config.js)

import { defineConfig } from 'vite';
import reduxHmr from 'vite-plugin-redux-hmr';

export default defineConfig({
  plugins: [
    reduxHmr({
      // Required:
      storeIndexFilePath: 'src/store/index.ts';
      storeReducersFilePath: 'src/store/reducers/index.ts',

      // Optional, defaults given for reference:
      storeVariableName: 'store', // change this to "myCustomStoreVar" in case you assigned your configureStore()/createStore() result to something different from "store"
      wrapReducersFunction: '(reducers) => reducers' // change this to something else like "(reducers) => rememberReducer(reducers)" in case you have a top-level reducer like the one from the "redux-rememeber" library
    })
  ]
});
1.0.1

2 years ago

1.0.0

2 years ago