I've followed the documentation at: https://vite-ruby.netlify.app/config/#ssr-options-experimental and built a quick example SSR app to test out if we can do SSR in our Rails app that's using this plugin to add in React JS views... the code is as follows:
ssr.tsx in app/javascript/ssr/ssr.tsx:
import React from "react";
import ReactDOMServer from "react-dom/server";
const App = () => {
return (
<div className="flex h-full items-center justify-center">
Hello from SSR
</div>
);
};
export function render() {
const html = ReactDOMServer.renderToString(
<React.StrictMode>
<App />
</React.StrictMode>
);
return { html };
}
We then call: bin/vite build --ssr which results with:
Building with Vite ⚡️
vite v5.0.12 building SSR bundle for production...
transforming...
✓ 1 modules transformed.
rendering chunks...
../../public/vite-ssr/ssr.js 0.49 kB │ map: 0.85 kB
✓ built in 285ms
Build with Vite complete: /Users/cameron/myapp/public/vite
And the contents of that built file:
import { jsx } from 'react/jsx-runtime';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
const App = () => {
return /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: "Hello from SSR" });
};
function render() {
const html = ReactDOMServer.renderToString(
/* @__PURE__ */ jsx(React.StrictMode, { children: /* @__PURE__ */ jsx(App, {}) })
);
return { html };
}
export { render };
//# sourceMappingURL=ssr.js.map
Then I have tried running: bin/vite ssr to run the SSR version (documentation doesn't mention anymore steps)
But the command just runs with no output and then that's it... is there missing step?
I've followed the documentation at: https://vite-ruby.netlify.app/config/#ssr-options-experimental and built a quick example SSR app to test out if we can do SSR in our Rails app that's using this plugin to add in React JS views... the code is as follows:
ssr.tsx
inapp/javascript/ssr/ssr.tsx
:We then call:
bin/vite build --ssr
which results with:And the contents of that built file:
Then I have tried running:
bin/vite ssr
to run the SSR version (documentation doesn't mention anymore steps)But the command just runs with no output and then that's it... is there missing step?
In the ViteJS documentation they mention using an express server: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react/server.js - but you don't mention this anywhere and it seems implied (even in the Inertia example you provide at: https://github.com/ElMassimo/inertia-rails-ssr-template) that a custom express server isn't required and all the additional parts come built in... the documentation does mention a nodejs file... but all I see generated is that JSX output I provided above.
Can you point me in the correct direction for what's actually missing? or is there a bug from the CLI?