gpt4 book ai didi

javascript - webpack-dev-server 启用功能,然后在 Webpack 配置中使用 "host"选项时断开连接两次

转载 作者:行者123 更新时间:2023-12-05 05:53:26 24 4
gpt4 key购买 nike

将 webpack-dev-server 从 3.11.0 更新到 4.4.0 后,当我在我的 Webpack 配置文件中的 devServer 下使用“主机”选项时,热重载不再有效。我的控制台显示 WDS 连接了两次,随后断开连接:

[HMR] Waiting for update signal from WDS...
[webpack-dev-server] Hot Module Replacement enabled.
[webpack-dev-server] Live Reloading enabled.
[webpack-dev-server] Disconnected!
[webpack-dev-server] Trying to reconnect...
[webpack-dev-server] Hot Module Replacement enabled.
[webpack-dev-server] Live Reloading enabled.
[webpack-dev-server] Disconnected!

当我删除“主机”选项并恢复为“本地主机”时,热重载始终如一。

我的 webpack 配置文件的 devServer 部分:

devServer: {
port: 3000,
host: 'app.ddev.site',
allowedHosts: 'auto',
open: true,
hot: true,
proxy: {
'/xhr': 'http://localhost:7777',
},
},

Webpack 包版本:

"webpack": "^5.61.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.4.0"

与“npm run dev”相关的脚本:

"client": "cross-env NODE_ENV=development webpack serve --config=config/webpack.dev.js",
"dev": "concurrently \"npm run start-local\" \"npm run client\"",
"start-local": "nodemon src/server/start.js",

感谢任何帮助!提前致谢。

最佳答案

我认为您的 allowedHosts 设置可能是罪魁祸首。

根据 the docs ,您可能会成功:

allowedHosts: ['all']

关于javascript - webpack-dev-server 启用功能,然后在 Webpack 配置中使用 "host"选项时断开连接两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69901768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com