-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Question] How to enable Server side rendering with Webpack externals from Sprocket #2085
Comments
cc @BookOfGreg to see if he has any insight |
I wonder how having that externals statement affects how webpack works... |
thanks @BookOfGreg for the suggestion, I tried that first and ran into a different issue (on the client side like you said), the SSR works really well. I can see the DOM in "View Source". However, all the CSS were messed up during hydrating due to React being loaded twice and generated different class names. Also the React duplication error suggestion was shown. That's why I tried webpack Re: 2 separate webpacks for the 2 pack files, I have no idea how to set that up |
Perhaps an issue on Webpack itself would help summon someone who knows how to manage externals in that way. |
@jakeNiemiec @gauravtiwari we should probably start closing some of these issues to cut down the number of open issues. The solution to this question is that SSR requires a different webpack config so that there are no references to things like window as SSR is executed on the server where there is no window. |
@justin808 I agree, but I try to be very carful with which issues I force-close. I have been on the receiving-end of an issue purge. The end result was many new issues based on old issues without the context of the previous conversation. |
Hi
I have a legacy React app which uses
react-rails
and require React via Sprocket, React is available aswindow.React
on the client side. When we add new UI features and pages, we decided to usewebpacker
and have React available from global externals. Here's ourenvironment.js
However, this approach doesn't work with server-side rendering because React is not available. I tried to add
react
topackage.json
and inserver_rendering.js
but it doesn't seem to helpAny help is appreciated, thank you.
PS: SSR only needs React not jQuery and the error was
ExecJS: ReferenceError: React is not defined
The text was updated successfully, but these errors were encountered: