16 lines
430 B
Plaintext
16 lines
430 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>...
|
|
```
|
|
|
|
With hot module reloading or watch mode, Bun reloads whenever `./file.html` changes.
|