bun嵌入文件

index.ts:

// this becomes an internal file path
import html from "./index.html" with { type: "file" };
import { file } from "bun";

export default {
    fetch(req) {
        // Embedded files can be streamed from Response objects
        return new Response(file(html));
    },
};

index.html:

Hello world!

编译:

bun build index.ts --outfile demo --compile

运行:

./demo
posted @ 2024-07-21 23:20  卓能文  阅读(1)  评论(0编辑  收藏  举报