Skip to content

Commit

Permalink
expose onLoadPageFile
Browse files Browse the repository at this point in the history
  • Loading branch information
codehz committed Dec 20, 2024
1 parent 28050f4 commit 6d7f4ee
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export async function build({
minify = Bun.env.NODE_ENV === "production",
define,
plugins,
onLoadPageFile = async ({ path, loader }) => {
const contents = await Bun.file(path).text();
return {
contents: contents.replaceAll(
/\/\/\s*@server-side[^\n\S]*\n[^\n]+\n/g,
""
),
loader,
};
},
}: {
baseDir: string;
buildDir?: string;
Expand All @@ -23,6 +33,7 @@ export async function build({
minify?: boolean;
define?: Record<string, string>;
plugins?: import("bun").BunPlugin[];
onLoadPageFile?: import("bun").OnLoadCallback;
}) {
const entrypoints = [join(baseDir, hydrate)];
const absPageDir = join(baseDir, pageDir);
Expand Down Expand Up @@ -81,16 +92,7 @@ export async function build({
);
build.onLoad(
{ namespace: "client", filter: /\.ts[x]$/ },
async ({ path, loader }) => {
const contents = await Bun.file(path).text();
return {
contents: contents.replaceAll(
/\/\/\s*@server-side[^\n\S]*\n[^\n]+\n/g,
""
),
loader,
};
}
onLoadPageFile
);
},
},
Expand Down

0 comments on commit 6d7f4ee

Please sign in to comment.