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-claude-bun-git-module/aYd6IH1DX0gD-k_I/icons/typescript.svg?fit=max&auto=format&n=aYd6IH1DX0gD-k_I&q=85&s=49fc2d2e9587ce2222ea6cc2b60db513file.ts
import html from "./file.html" with { type: "text" };

console.log(html); // <!DOCTYPE html><html><head>...
This can also be used with hot module reloading and/or watch mode to force Bun to reload whenever the ./file.html file changes.