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