entry中添加了HMR相关文件,同时添加HMR插件以修复热重载不生效的问题

This commit is contained in:
pqcqaq 2024-10-13 10:56:59 +08:00
parent 6b01e3718b
commit c18e7c94ff
1 changed files with 10 additions and 1 deletions

View File

@ -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