Skip to content

Commit 584f4f8

Browse files
committed
replaced react-hot-loader with react-refresh
1 parent 44f81b8 commit 584f4f8

File tree

7 files changed

+90
-86
lines changed

7 files changed

+90
-86
lines changed

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function babelConfig(api) {
2020
'transform-react-remove-prop-types',
2121
'transform-react-pure-class-to-function',
2222
'@babel/plugin-transform-runtime',
23-
'react-hot-loader/babel',
23+
'react-refresh/babel',
2424

2525
// Stage 2 https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2
2626
['@babel/plugin-proposal-decorators', { legacy: true }],

package.json

+14-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"git add"
1919
]
2020
},
21-
2221
"husky": {
2322
"hooks": {
2423
"pre-commit": "lint-staged"
@@ -38,7 +37,9 @@
3837
"^.+\\.(js|jsx)$": "babel-jest",
3938
".+\\.(css|styl|less|sass|scss)$": "<rootDir>/node_modules/jest-css-modules-transform"
4039
},
41-
"setupFilesAfterEnv": ["<rootDir>/setupTests.js"],
40+
"setupFilesAfterEnv": [
41+
"<rootDir>/setupTests.js"
42+
],
4243
"moduleFileExtensions": [
4344
"css",
4445
"scss",
@@ -58,15 +59,14 @@
5859
"dependencies": {
5960
"@babel/plugin-transform-react-constant-elements": "7.16.0",
6061
"@babel/plugin-transform-react-inline-elements": "7.16.0",
62+
"babel-plugin-import": "^1.13.1",
6163
"babel-plugin-transform-react-pure-class-to-function": "1.0.1",
6264
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
63-
"babel-plugin-import": "^1.13.1",
6465
"core-js": "3.19.2",
6566
"lodash": "4.17.21",
6667
"prop-types": "15.7.2",
6768
"react": "16.14.0",
68-
"react-dom": "16.14.0",
69-
"react-hot-loader": "4.13.0"
69+
"react-dom": "16.14.0"
7070
},
7171
"resolutions": {
7272
"babel-core": "7.0.0-bridge.0"
@@ -84,15 +84,16 @@
8484
"@babel/plugin-syntax-import-meta": "7.10.4",
8585
"@babel/plugin-transform-runtime": "7.16.4",
8686
"@babel/preset-env": "7.16.4",
87-
"babel-preset-react-optimize": "1.0.1",
8887
"@babel/preset-react": "7.16.0",
8988
"@babel/register": "7.16.0",
9089
"@babel/runtime": "7.16.3",
90+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
9191
"babel-core": "7.0.0-bridge.0",
9292
"babel-eslint": "10.1.0",
9393
"babel-jest": "25.5.1",
9494
"babel-loader": "8.2.3",
9595
"babel-plugin-lodash": "3.3.4",
96+
"babel-preset-react-optimize": "1.0.1",
9697
"browserslist": "4.18.1",
9798
"clean-webpack-plugin": "3.0.0",
9899
"connect-history-api-fallback": "1.6.0",
@@ -103,37 +104,38 @@
103104
"eslint": "7.32.0",
104105
"eslint-config-airbnb": "18.2.1",
105106
"eslint-config-prettier": "7.2.0",
106-
"eslint-webpack-plugin": "2.6.0",
107107
"eslint-plugin-import": "2.25.3",
108108
"eslint-plugin-jest": "23.20.0",
109109
"eslint-plugin-jsx-a11y": "6.5.1",
110110
"eslint-plugin-prettier": "3.4.1",
111111
"eslint-plugin-react": "7.27.1",
112112
"eslint-watch": "7.0.0",
113+
"eslint-webpack-plugin": "2.6.0",
113114
"file-loader": "6.2.0",
114-
"koa-connect": "2.1.0",
115115
"html-webpack-plugin": "4.5.2",
116-
"script-ext-html-webpack-plugin": "2.1.5",
117116
"husky": "6.0.0",
118117
"identity-obj-proxy": "3.0.0",
119118
"jest": "25.5.4",
120119
"jest-css-modules-transform": "4.3.0",
121120
"jest-enzyme": "7.1.2",
122121
"jest-fetch-mock": "3.0.3",
123122
"jsdom": "16.7.0",
123+
"koa-connect": "2.1.0",
124124
"lint-staged": "11.2.6",
125125
"mini-css-extract-plugin": "0.12.0",
126-
"sass": "1.44.0",
127126
"npm-check-updates": "10.3.1",
127+
"optimize-css-assets-webpack-plugin": "6.0.1",
128128
"prettier": "2.5.0",
129129
"pretty-quick": "2.0.2",
130+
"react-refresh": "^0.11.0",
131+
"sass": "1.44.0",
130132
"sass-loader": "8.0.2",
133+
"script-ext-html-webpack-plugin": "2.1.5",
131134
"style-loader": "1.3.0",
135+
"terser-webpack-plugin": "4.2.3",
132136
"webpack": "4.46.0",
133137
"webpack-cli": "4.9.1",
134138
"webpack-dev-server": "3.11.3",
135-
"optimize-css-assets-webpack-plugin": "6.0.1",
136-
"terser-webpack-plugin": "4.2.3",
137139
"webpack-merge": "4.2.2"
138140
}
139141
}

src/App.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import { hot } from 'react-hot-loader/root';
2+
33
import HelloWorld from './components/hello-world';
44

55
class App extends Component {
@@ -13,4 +13,4 @@ class App extends Component {
1313
}
1414
}
1515

16-
export default hot(App);
16+
export default App;

webpack/webpack.common.js

-14
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ module.exports = {
1010
entry: commonPaths.entryPath,
1111
module: {
1212
rules: [
13-
{
14-
test: /\.(js|jsx)$/,
15-
loader: 'babel-loader',
16-
exclude: /(node_modules)/,
17-
options: {
18-
presets: ['@babel/react'],
19-
plugins: [['import', { libraryName: 'antd', style: true }]],
20-
},
21-
},
22-
{
23-
test: /\.(js|jsx)$/,
24-
use: 'react-hot-loader/webpack',
25-
include: /node_modules/,
26-
},
2713
{
2814
test: /\.(png|jpg|gif|svg)$/,
2915
use: [

webpack/webpack.dev.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const webpack = require('webpack');
2-
1+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
32
const commonPaths = require('./paths');
43

54
module.exports = {
@@ -11,6 +10,18 @@ module.exports = {
1110
},
1211
module: {
1312
rules: [
13+
{
14+
test: /\.(js|jsx)$/,
15+
loader: 'babel-loader',
16+
exclude: /(node_modules)/,
17+
options: {
18+
presets: ['@babel/react'],
19+
plugins: [
20+
['import', { libraryName: 'antd', style: true }],
21+
require.resolve('react-refresh/babel'),
22+
].filter(Boolean),
23+
},
24+
},
1425
{
1526
test: /\.(css|scss)$/,
1627
use: [
@@ -35,5 +46,5 @@ module.exports = {
3546
compress: true,
3647
hot: true,
3748
},
38-
plugins: [new webpack.HotModuleReplacementPlugin()],
49+
plugins: [new ReactRefreshWebpackPlugin()],
3950
};

webpack/webpack.prod.js

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ module.exports = {
4949

5050
module: {
5151
rules: [
52+
{
53+
test: /\.(js|jsx)$/,
54+
loader: 'babel-loader',
55+
exclude: /(node_modules)/,
56+
options: {
57+
presets: ['@babel/react'],
58+
plugins: [['import', { libraryName: 'antd', style: true }]],
59+
},
60+
},
5261
{
5362
test: /\.(css|scss)$/,
5463
use: [

0 commit comments

Comments
 (0)