From c18e7c94ff481f1d8a05ee2b3a413f73a82dec6a Mon Sep 17 00:00:00 2001 From: pqcqaq <905739777@qq.com> Date: Sun, 13 Oct 2024 10:56:59 +0800 Subject: [PATCH] =?UTF-8?q?entry=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86HMR?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6=EF=BC=8C=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0HMR=E6=8F=92=E4=BB=B6=E4=BB=A5=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=83=AD=E9=87=8D=E8=BD=BD=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/web/webpack.config.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/web/webpack.config.js b/config/web/webpack.config.js index 82b42d5..f280d61 100644 --- a/config/web/webpack.config.js +++ b/config/web/webpack.config.js @@ -235,7 +235,14 @@ module.exports = function (webpackEnv) { (shouldUseSourceMap ? 'source-map' : isEnvStaging ? 'eval-cheap-module-source-map' : 'nosources-source-map'), // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. - entry: paths.appIndexJs, + entry: [ + // 模块热替换的运行时代码 + 'webpack/hot/dev-server.js', + // 用于 web 套接字传输、热重载逻辑的 web server 客户端 + 'webpack-dev-server/client/index.js?hot=true&live-reload=true', + // oak项目入口 + paths.appIndexJs, + ], output: { // The build folder. path: paths.appBuild, @@ -802,6 +809,8 @@ module.exports = function (webpackEnv) { : undefined ) ), + // 添加HMR插件支持 + new webpack.HotModuleReplacementPlugin(), // Inlines the webpack runtime script. This script is too small to warrant // a network request. // https://github.com/facebook/create-react-app/issues/5358