Skip to main content
要在 Bun 中将 .html 文件作为文本文件导入,使用导入语句中的 type: "text" 属性。
https://mintcdn.com/teemo/2s-4Z6VdGqiCeBNX/icons/typescript.svg?fit=max&auto=format&n=2s-4Z6VdGqiCeBNX&q=85&s=087b260066909db1cd3e9c7292bc34b2file.ts
import html from "./file.html" with { type: "text" };

console.log(html); // <!DOCTYPE html><html><head>...
这也可在热模块重载和/或监视模式下使用,以强制 Bun 在 ./file.html 文件更改时重新加载。