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

时间:2016-03-19 05:23:42

标签: webpack react-router react-slingshot

我使用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?

2 个答案:

答案 0 :(得分:2)

只是为了完整性和任何有旧版弹弓问题的人。 issue 75中也提到了这一点,并通过替换:

修复了here
publicPath: '',

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

另外,必须阅读:https://medium.com/@rajaraodv/webpacks-hmr-react-hot-loader-the-missing-manual-232336dc0d96#.ejpsmve8f

或尝试热重装3: 例如:https://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915