1.0.5 • Published 12 months ago

react-refresh-hotfix v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

react-refresh-hotfix npm version

react-refresh-hotfix is react-refresh-webpack-plugin additional feature support, to fix some issues like:

Although the React official team doesn't consider this a bug, here is an alternative to improve the HMR development experience for others.

Installation

# use npm
npm install -D react-refresh-hotfix
# use yarn
yarn add -D react-refresh-hotfix

Usage

First, follow the official guide react-refresh-webpack-plugin

Then, add the following to your webpack config:

const  refreshFixPlugin = require("react-refresh-hotfix");
const isDevelopment = process.env.NODE_ENV === "development";
module.exports = {
  plugins: [
    isDevelopment && new refreshFixPlugin(),
  ].filter(Boolean)
}

Or, you can use the following configuration to avoid the need to modify the webpack config:

const isDevelopment = process.env.NODE_ENV === "development";

module.exports = {
  alias: {
    ...(isDevelopment ? { react$: 'react-refresh-hotfix/react' } : {}),
  },
  modules: {
    rules: [
      isDevelopment && {
        test: /\.[m|c]?[jt]sx?$/,
        exclude: /node_modules/,
        use: ['react-refresh-hotfix/loader'],
      },
    ].filter(Boolean)
  }
};
1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

1 year ago