Skip to content

Commit

Permalink
fix: cwd when building client components
Browse files Browse the repository at this point in the history
  • Loading branch information
joseferben committed Oct 6, 2024
1 parent d976bc4 commit 1eb221a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions example/2-client-component/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Hono } from "hono";
import { serveStatic } from "hono/bun";
import { build } from "plainstack/bun";
import { render } from "plainstack/client";
import { Counter } from "./counter";
import { Counter } from "./client/counter";

const app = new Hono();

app.use("/static/*", serveStatic({ root: "./example/2-client-component" }));

await build({
entrypoints: ["example/2-client-component/counter.tsx"],
entrypoints: "example/2-client-component/client",
outdir: "example/2-client-component/static",
});

Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions src/bun.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Database } from "bun:sqlite";
import { randomBytes } from "node:crypto";
import { readdir } from "node:fs/promises";
import { join } from "node:path";
import type { BuildConfig as BunBuildConfig } from "bun";
import { CamelCasePlugin, Kysely } from "kysely";
import { BunSqliteDialect } from "kysely-bun-sqlite";
Expand Down Expand Up @@ -46,12 +47,15 @@ type BuildConfig = Omit<BunBuildConfig, "entrypoints"> & {
export async function build(options: BuildConfig) {
const entrypointfiles =
typeof options.entrypoints === "string"
? await readdir(options.entrypoints)
? await readdir(options.entrypoints).then((files) =>
files.map((file) => join(options.entrypoints as string, file)),
)
: options.entrypoints;
console.log(entrypointfiles);
return await Bun.build({
outdir: "static",
sourcemap: "linked",
minify: false, // TODO
minify: prod(),
...options,
entrypoints: entrypointfiles,
});
Expand Down

0 comments on commit 1eb221a

Please sign in to comment.