mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
18 lines
514 B
Plaintext
18 lines
514 B
Plaintext
---
|
|
title: Import a HTML file as text
|
|
sidebarTitle: Import HTML
|
|
mode: center
|
|
---
|
|
|
|
To import a `.html` file in Bun as a text file, use the `type: "text"` attribute in the import statement.
|
|
|
|
```ts file.ts icon="/icons/typescript.svg"
|
|
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.
|
|
|
|
This feature was added in Bun v1.1.5.
|