Closed darkadept closed 7 years ago
Ah, shoot, I was accidentally loading makeRoutes
on the server side in dev mode even though they're only meant to be used in prod. In dev mode (which doesn't do full SSR) it doesn't work because there's no babel plugin configured to handle CSS requires.
Ahh that makes sense. I have to admit I still don't 100% understand the createSSR file. It's still magic to me. :-) I'll need to parse over it line by line one of these days. The PR fixes this issue, thanks!
No problem, thanks for reporting this!
createSSR is not too complicated, it parses assets.json
which contain paths to the files produced by webpack.config.prod.js
. It passes those to <Html>
, which creates <script>
tags for the assets. The other thing it does it call react-router
's match
to get all the props for the route requested, and sends those into <Html>
as well. The only other tricky thing is it has to do store.dispatch(push(location))
before rendering.
This is a bit of an odd error. I made a layout component that renders a bit of markup and then
this.props.children
and added some CSS markup in a separate.css
file. I add it to the root route atsrc/universal/routes/index.js
like this:When I try to run in dev mode I get this error:
I have a repro here: https://github.com/koretech/crater/tree/router-component-css-error
If you comment out the CSS imports it works fine.
If I get rid of the
component: Layout
line in the route file and instead wrap what's inApp.js
with<Layout></Layout>
it works fine. You can see the CSS and component working fine here: https://github.com/koretech/crater/tree/router-component-css-alternative.It almost seems like this is a webpack or babel issue but I can't seem to pin it down.