mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
- Refactored to introduce handleSsr
function in @open-gsio/client/server/index.ts
for streamlined SSR handling.
- Replaced inline SSR logic in `AssetService.ts` with `handleSsr` import. - Enhanced `build:client` script to ensure server directory creation. - Updated dependencies and devDependencies across multiple packages for compatibility improvements.
This commit is contained in:
@@ -10,10 +10,15 @@
|
||||
"generate:robotstxt": "bun ./scripts/generate_robots_txt.js open-gsio.seemueller.workers.dev",
|
||||
"generate:fonts": "cp -r ../../node_modules/katex/dist/fonts public/static"
|
||||
},
|
||||
"dependencies": {
|
||||
"exports": {
|
||||
"./server/index.ts": {
|
||||
"import": "./server/index.ts",
|
||||
"types": "./server/index.ts"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@open-gsio/env": "workspace:*",
|
||||
"@open-gsio/scripts": "workspace:*",
|
||||
"@anthropic-ai/sdk": "^0.32.1",
|
||||
"@chakra-ui/react": "^2.10.6",
|
||||
"@cloudflare/workers-types": "^4.20241205.0",
|
||||
"@emotion/react": "^11.13.5",
|
||||
@@ -48,11 +53,11 @@
|
||||
"react-textarea-autosize": "^8.5.5",
|
||||
"shiki": "^1.24.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vike": "0.4.193",
|
||||
"vite": "^6.3.5",
|
||||
"vike": "^0.4.235",
|
||||
"vite": "^7.0.0",
|
||||
"vite-plugin-pwa": "^1.0.0",
|
||||
"vitest": "^3.1.4",
|
||||
"bun": "*",
|
||||
"@types/bun": "*"
|
||||
"bun": "^1.2.17",
|
||||
"@types/bun": "^1.2.17"
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,20 @@
|
||||
import { renderPage } from 'vike/server';
|
||||
|
||||
// This is what makes SSR possible. It is consumed by @open-gsio/server
|
||||
export default renderPage;
|
||||
|
||||
export { handleSsr };
|
||||
|
||||
async function handleSsr(url: string, headers: Headers) {
|
||||
const pageContextInit = {
|
||||
urlOriginal: url,
|
||||
headersOriginal: headers,
|
||||
fetch: (...args: Parameters<typeof fetch>) => fetch(...args),
|
||||
};
|
||||
const pageContext = await renderPage(pageContextInit);
|
||||
const { httpResponse } = pageContext;
|
||||
const stream = httpResponse.getReadableWebStream();
|
||||
return new Response(stream, {
|
||||
headers: httpResponse.headers,
|
||||
status: httpResponse.statusCode,
|
||||
});
|
||||
}
|
||||
|
@@ -7,30 +7,30 @@ import { VitePWA } from 'vite-plugin-pwa';
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { configDefaults } from 'vitest/config';
|
||||
|
||||
const prebuildPlugin = () => ({
|
||||
name: 'prebuild',
|
||||
config(config, { command }) {
|
||||
if (command === 'build') {
|
||||
child_process.execSync('bun generate:sitemap');
|
||||
console.log('Generated Sitemap -> public/sitemap.xml');
|
||||
child_process.execSync('bun run generate:robotstxt');
|
||||
console.log('Generated robots.txt -> public/robots.txt');
|
||||
child_process.execSync('bun run generate:fonts');
|
||||
console.log('Copied fonts -> public/static/fonts');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default defineConfig(({ command }) => {
|
||||
const customPlugins = [
|
||||
{
|
||||
name: 'sitemap-generator',
|
||||
buildStart(options) {
|
||||
if (command === 'build') {
|
||||
child_process.execSync('bun run generate:sitemap');
|
||||
console.log('Generated Sitemap -> public/sitemap.xml');
|
||||
child_process.execSync('bun run generate:robotstxt');
|
||||
console.log('Generated robots.txt -> public/robots.txt');
|
||||
child_process.execSync('bun run generate:fonts');
|
||||
console.log('Copied fonts -> public/static/fonts');
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
return {
|
||||
mode: 'production',
|
||||
plugins: [
|
||||
...customPlugins,
|
||||
prebuildPlugin(),
|
||||
react(),
|
||||
vike({
|
||||
prerender: true,
|
||||
disableAutoFullBuild: false,
|
||||
}),
|
||||
react(),
|
||||
// PWA plugin saves money on data transfer by caching assets on the client
|
||||
/*
|
||||
For safari, use this script in the console to unregister the service worker.
|
||||
@@ -60,7 +60,7 @@ export default defineConfig(({ command }) => {
|
||||
server: {
|
||||
port: 3000,
|
||||
proxy: {
|
||||
// proxies requests to server
|
||||
// proxies requests in development
|
||||
'/api': {
|
||||
target: 'http://localhost:3003',
|
||||
},
|
||||
|
Reference in New Issue
Block a user