我使用react slingshot启动项目为我的react / redux应用程序。当我使用/foo
之类的路由时,热重新加载效果很好,但我发现热重新加载不适用于像/foo/bar
这样的子路由。我没有对开箱即用的webpack配置文件进行任何更改,可以在此处找到https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.js
当我有以下路由配置时,我在CreateOrder组件上得到404 GET http://localhost:3004/orders/c344e97ed1fbc2923017.hot-update.json 404 (Not Found)
:
<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>
但是当我将订单/创建的路径更改为刚创建时,它不会返回404。
似乎热门更新中间件试图从/ orders子路由中获取hot-update.json?
答案 0 :(得分:2)
只是为了完整性和任何有旧版弹弓问题的人。 issue 75中也提到了这一点,并通过替换:
修复了herepublicPath: '',
与
publicPath: '/',
webpack.config.js
中的
更新: 从reduckted的评论中,publicPath必须以斜线开头和结尾。替换:
publicPath: 'dist/',
与
publicPath: '/dist/',
答案 1 :(得分:0)
publicPath配置对我来说不是问题。 如果您正在使用redux,可以试试这个。
由于某些随机原因,redux-devtools
不允许热重载。尝试从根组件和redux compose
config。
注意:在商店配置中使用带有此配置的redux devtool浏览器扩展程序:window.devToolsExtension ? window.devToolsExtension() : f => f
或尝试热重装3: 例如:https://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915