react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

Hot reload not working with React-Router/History API #208

Closed ncksllvn closed 8 years ago

ncksllvn commented 8 years ago

I've found that when using routes going deeper than one level, the hot update returns a 404.

app.js:26 GET http://localhost:8000/app/users/assets/445b04c0334ebe2a49c5.hot-update.json 404 (Not Found)

Font Awesome has the same problem when its LESS files try to reference its font directory:

http://localhost:8000/app/users/assets/926c93d201fe51c8f351e858468980c3.woff2 Failed to load resource: the server responded with a status of 404 (Not Found)

This problem doesn't happen when using the webpack-dev-server/ in the URL so I'm not sure if this is really an issue, but that doesn't really play well with testing using the React Router since it's no longer storing the URL in the address bar.

weblogixx commented 8 years ago

Hi @ncksllvn,

I currently have a project using deeper routes in react router without problems. Do you have historyApiFallback set in your webpack config? Without this, routes will not update.

However, it should be enabled by default in cfg/base.js per default. Could you send your react router and webpack config?

ncksllvn commented 8 years ago

I actually just found this problem. The output.publicPath property defined in cfg/base.js has a leading .. Removing that fixed the 404's I was getting.

publicPath: `${defaultSettings.publicPath}`

I don't recall ever changing that file though so that makes me think this is a bug.

ncksllvn commented 8 years ago

Actually I suppose this is a problem with the react-webpack-template project, not the generator. Is that right?

weblogixx commented 8 years ago

Seems like that. I will close this issue so we can continue in the webpack template.

pingfengafei commented 7 years ago

@ncksllvn ,thx, It also happens to me when using webpack-dev-sever without config outPath : '/'.