mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
* Fixes #3449 Fixes https://github.com/oven-sh/bun/issues/10206 Fixes https://github.com/oven-sh/bun/issues/5710 * Apply formatting changes * Update loaders.md * Update text-loader-fixture-import.ts * Add guide * Update bundler_loader.test.ts * Address comment --------- Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
16 lines
435 B
Markdown
16 lines
435 B
Markdown
---
|
|
name: Import HTML file as text
|
|
---
|
|
|
|
To import a `.html` file in Bun as a text file, use the `type: "text"` attribute in the import statement.
|
|
|
|
```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.
|
|
|
|
This feature was added in Bun v1.1.5.
|