diff --git a/package.json b/package.json index 9e49699..21a4340 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build", + "build": "vite build && bun build dist/server/index.js --target bun --outdir dist", "preview": "vite preview", "deploy": "wrangler deploy", "cf-typegen": "wrangler types --env-interface CloudflareBindings" diff --git a/plugins/ssrPlugin.ts b/plugins/ssrPlugin.ts index 01906e7..860b016 100644 --- a/plugins/ssrPlugin.ts +++ b/plugins/ssrPlugin.ts @@ -26,7 +26,7 @@ export function clientFirstBuild(): Plugin { config.builder.buildApp = async (builder) => { const clientEnvironment = builder.environments.client; const workerEnvironments = Object.keys(builder.environments) - .filter((name) => name !== "client") + .filter((name) => name !== "client" && name !== "ssr") .map((name) => builder.environments[name]); // console.log('Client First Build Plugin: Starting builds...', workerEnvironments) // Client build first @@ -112,7 +112,6 @@ export default function ssrPlugin(): Plugin[] { resolveId(id, importer, options) { if (!id.startsWith('@httpClientAdapter')) return const pwd = process.cwd() - console.log('Resolving httpClientAdapter in', pwd, 'for', {id, importer, options}) return path.resolve( __dirname, options?.ssr @@ -136,7 +135,8 @@ export default function ssrPlugin(): Plugin[] { const clientBuild = viteConfig.environments.client.build; clientBuild.manifest = true; clientBuild.rollupOptions = clientBuild.rollupOptions || {}; - clientBuild.rollupOptions.input = "src/client.ts"; + // clientBuild.rollupOptions.input = "src/client.ts"; + // clientBuild.outDir = "dist/client"; if (!viteConfig.environments.ssr) { const manifestPath = path.join(clientBuild.outDir as string, '.vite/manifest.json') try { diff --git a/src/index.tsx b/src/index.tsx index bb93da0..6e3ec83 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,13 +9,16 @@ import { cors } from "hono/cors"; import { jwtRpc, rpcServer } from './api/rpc'; import isMobile from 'is-mobile'; import { useAuthStore } from './stores/auth'; -import { serveStatic } from "hono/bun"; +// import { serveStatic } from "hono/bun"; +import { serveStatic } from "hono/serve-static"; import { cssContent } from './lib/primeCssContent'; import { styleTags } from './lib/primePassthrough'; // @ts-ignore import Base from '@primevue/core/base'; const app = new Hono() const defaultNames = ['primitive', 'semantic', 'global', 'base', 'ripple-directive'] +const isDev = import.meta.env.DEV; +console.log("process.versions?.bun:", (process as any).versions?.bun); // app.use(renderer) app.use('*', contextStorage()); app.use(cors(), async (c, next) => { @@ -27,7 +30,12 @@ app.use(cors(), async (c, next) => { c.set("isMobile", isMobile({ ua })); await next(); }, rpcServer); -app.use(serveStatic({ root: "./public" })) +if (!isDev) { + if ((process as any).versions?.bun) { + const { serveStatic } = await import("hono/bun"); + app.use(serveStatic({ root: "./dist/client" })) + } +} app.get("/.well-known/*", (c) => { return c.json({ ok: true }); }); diff --git a/src/routes/auth/login.vue b/src/routes/auth/login.vue index a14de68..ee70f42 100644 --- a/src/routes/auth/login.vue +++ b/src/routes/auth/login.vue @@ -1,8 +1,8 @@