Some server runtimes doesn't provide access to the filesystem, eg quickjs (see #125)
We use it only in one place - server.ts uses it to read manifest file and generate preload directives
There should be a way to configure Vite to embed manifest directly into SSR bundle. Some code I've found around that might be useful:
import fs from 'node:fs';
import path from 'node:path';
import { defineConfig } from 'vite';
export default defineConfig({
build: {
ssr: 'src/entry-server.js',
// ... other config
},
define: {
// Inject the manifest as a global constant
__SSR_MANIFEST__: JSON.parse(
fs.readFileSync(path.resolve(__dirname, './dist/client/.vite/ssr-manifest.json'), 'utf-8')
)
}
});
// entry-server.js
export async function render(url) {
// __SSR_MANIFEST__ is now available as a global object
const manifest = __SSR_MANIFEST__;
// Use it to resolve assets as usual
const appHtml = await renderApp(url);
return { appHtml, manifest };
}
worth exploring, as it would make SSR rendering a bit less complex and faster.
Some server runtimes doesn't provide access to the filesystem, eg quickjs (see #125)
We use it only in one place - server.ts uses it to read manifest file and generate preload directives
There should be a way to configure Vite to embed manifest directly into SSR bundle. Some code I've found around that might be useful:
worth exploring, as it would make SSR rendering a bit less complex and faster.