Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 带有react路由器的网页包开发服务器热重新加载_Webpack_React Router_Webpack Dev Server - Fatal编程技术网

Webpack 带有react路由器的网页包开发服务器热重新加载

Webpack 带有react路由器的网页包开发服务器热重新加载,webpack,react-router,webpack-dev-server,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}/>

我使用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>
似乎是在资源路径中添加路由路径,但webpack仅在“/assets/”下生成热重新加载文件。 然而,若我在react路由器中使用hashHistory,我并没有问题。只有当我使用broswerHistory时

这是我的网页配置:

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

此外,如果我转到localhost:9300/,我可以看到应用程序,并且路由正常工作,例如localhost:9300/app/payment/export。但是,如果我键入该url并按enter键,它会抱怨localhost:9300/app/payment/export/assets/app.js未找到。它试图在路由路径下找到/assets/app.js,这是不对的。另外,如果我转到localhost:9300/,我可以看到该应用,并且路由正常工作,例如localhost:9300/app/payment/export。但是,如果我键入该url并按enter键,它会抱怨localhost:9300/app/payment/export/assets/app.js未找到。它试图在路由路径下找到/assets/app.js,这是不对的。
const path = require('path');
const srcPath = path.join(__dirname, '/../src');
...
{
publicPath: '/assets/',
srcPath: srcPath
}