Webpack-dev-server使用react-router进行热重装

时间:2016-09-26 02:02:10

标签: webpack react-router webpack-dev-server

我使用yeoman用react和webpack设置我的项目。 然后,我手动将react-router添加到项目中。 热重载工作正常,直到我有路径。

所以在我的index.js中,我有

<Provider store={store}>
<Router history={browserHistory}>
  <Route path="/" component={App}>
    <IndexRoute component={Dashboard}/>
    <Route path="/app" component={Nav}>
      <Route path="/app/payable/export" component={Export}/>
    </Route>
  </Route>
  <Route path="*" component={NotFound}/>
</Router>

热重载适用于组件:App和Dashboard因为路径只是“/".

但热重载对导出不起作用。 我收到了这个错误:

http://localhost:9300/app/payable/assets/31f035eb918b53b2078f.hot-update.json 404 (Not Found)

似乎它在资源路径中追加路径路径,但webpack只在“/ assets /”下生成热重载文件。 但是,如果我在react-router中使用hashHistory,我没有问题。只有当我使用broswerHistory。

这是我的webpack配置:

const path = require('path');
const srcPath = path.join(__dirname, '/../src');
...
{
publicPath: '/assets/',
srcPath: srcPath
}

0 个答案:

没有答案
相关问题