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

Question: Server-side rendering #259

Open chrishutchinson opened 8 years ago

chrishutchinson commented 8 years ago

Hey folks,

I have a simple generator-react-webpack project I'd like to server-side render.

Given Webpack is bundling the entire app into a single file (including my ReactDOM.render(<App />, document.getElementById('app')); line), I can't use ReactDOMServer.renderToString() because document isn't defined.

This app is going to be served statically, and so I'll be writing a simple node script to generate the HTML and store it somewhere (e.g. S3).

Any suggestions on how best to do this, given the webpack config in this generator, would be appreciated.

Thanks!

weblogixx commented 8 years ago

Hi @chrishutchinson,

I have not tried server side rendering in the current version. Would be interested in this, too. We are currently looking into giving the generator the possibility to use ssr. Have a look at https://github.com/weblogixx/react-webpack-template/issues/41 for the current status of this.