Skip to main content
To import a .html file in Bun as a text file, use the type: "text" attribute in the import statement.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35bfile.ts
import html from "./file.html" with { type: "text" };

console.log(html); // <!DOCTYPE html><html><head>...
With hot module reloading or watch mode, Bun reloads whenever ./file.html changes.