-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to disable server-side rendering? #290
Comments
You'll need the server render logic to determine which assets to add to the page. You can use Something like this: const StubComponent = props => null
const OnsenComponent = isBrowser ? require('onsen') : StubComponent
// inside render
<OnsenComponent /> This will mean the server uses StubComponent and never references window and the browser will require the onsen code that references window somewhere. |
Good idea - I'll try that next. Thanks, @tomatau |
No problem @marclar ! Let me know if it works please :) |
So it seems like it's working; no compilation errors, but I still have a couple of issues / questions. First, I get a warning like this, as the server-rendered component differs from the client-rendered one. Not sure there's an easy way to overcome that without abusing the Second, I've been having trouble importing the framework's CSS. I've tried a few different approaches but I'm guessing you'd know how to do this properly. There are files in the I added
What's the correct way to include these styles? Thanks very much |
These sounds like general problems that are with building universal components and configuring webpack. The first problem with diff between server and client is down to the component itself that has this issue. Running webpack on files inside your node_modules is just a webpack configuration thing. You can edit the webpack configs around the loaders for styling so that they also include @import "~onsenui/css/onsenui.min.css"; |
First of all, great boilerplate - thanks for publishing it.
Second, I'm trying to integrate with https://onsen.io and merely referencing one of the components returns
window is not defined
. I assume these components depend on awindow
object and won't easily integrate with a server-side rendering process.Is there a reasonable way to disable the server-side rendering? I'm looking in
render-app.js
and I found theisBrowser
utility but I still get the error even when I return early ifisBrowser === false
.The text was updated successfully, but these errors were encountered: