Skip to main content

Import a HTML file as text

还没翻译译自英文(bun.com)本页 3 段都还没译

To import a .html file in Bun as a text file, use the type: "text" attribute in the import statement.

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.

翻訳 © 2026 fanyi.dev · 原文 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)