问题描述
我正在.Net Core 2.0上构建React/Redux应用程序,因此我使用了提供的模板.当我通过Startup.cs禁用webpack HMR时,我一直遇到这个问题,基本上只是注释掉以下几行:
I'm in the process of building a React/Redux app on .Net Core 2.0, so I've used the template provided. I've been running into this issue when I disable the webpack HMR through my Startup.cs, basically just commenting out the following lines:
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true,
ReactHotModuleReplacement = true,
HotModuleReplacementClientOptions = new Dictionary<string, string>
{
{ "quiet", "true" }
}
});
但是,当我这样做时,客户端会为此__webpack_hmr发出一个get请求.这是VS中的输出:
However, when I do this, there is a get request coming from the client for this __webpack_hmr. Here is the output in VS:
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:34521/dist/__webpack_hmr
我现在正尝试禁用HMR,因为这会导致我的应用启动缓慢(不同的主题),但是我必须继续使用它,因为如果不能,它将继续为该资源执行ping操作.我也担心这将如何在生产中发挥作用.还有其他人碰到这个吗?有什么解决办法吗?
I'm trying to disable HMR for now because it's causing my app to start up slowly (different topic), but I have to keep it on because if not it'll keep pinging for this resource. I'm also worried about how this will act in production. Has anyone else run in to this? Any solution for it?
推荐答案
只需删除 wwwroot/dist
和 ClientApp/dist
文件夹,然后运行:
Simply remove wwwroot/dist
and ClientApp/dist
folders, and run:
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js
这将重建供应商依赖性,并允许重建您的代码.
This will rebuild the vendor dependencies, and allow your code to be rebuilt.
这篇关于使用.Net Core React/Redux模板,禁用Webpack HMR会导致"__webpack_hmr"不断被请求的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!