gpt4 book ai didi

webpack - React slingshot - 使用 React 路由器子路由时,Webpack 热中间件在 hot-update.json 上返回 404

转载 作者:行者123 更新时间:2023-12-03 22:44:32 26 4
gpt4 key购买 nike

我正在为我的 react/redux 应用程序使用 react slingshot starter 项目。当我使用像 /foo 这样的路由时,热重载效果很好。但我发现热重载不适用于像 /foo/bar 这样的子路由.我没有对开箱即用的 webpack 配置文件进行任何更改,可以在此处找到 https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.js

我收到 404 GET http://localhost:3004/orders/c344e97ed1fbc2923017.hot-update.json 404 (Not Found)当我有以下路由配置时,在 CreateOrder 组件上:

<Route path="/" component={App}>
<Route path="login" component={Login} />
<Route path="orders" component={OrderPanel} />
<Route path="orders/create" component={CreateOrder} />
<Route path="*" component={NotFoundPage} />
</Route>

但是当我将路径从 orders/create 更改为 just create 时,它​​不会返回 404。

似乎热更新中间件正试图从/orders 子路由中获取 hot-update.json?

最佳答案

只是为了完整性以及任何使用旧版本弹弓遇到此问题的人。
issue 75中也提到了这一点并修复 here通过替换:

publicPath: '',


publicPath: '/',

webpack.config.js
更新:
根据 reduckted 的评论,publicPath 必须以斜杠开头和结尾。代替:
publicPath: 'dist/',


publicPath: '/dist/',

关于webpack - React slingshot - 使用 React 路由器子路由时,Webpack 热中间件在 hot-update.json 上返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36098193/

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