0.0.2 • Published 8 months ago
bun-html-importer v0.0.2
bun-html-importer
Plugin to import html as a file in bun projects
To run plugin:
import { plugin } from "bun";
import { bunHtmlImporterPlugin } from "bun-html-importer"
plugin(bunHtmlImporterPlugin)
here is sample implementation in Elysia project:
First we need to preload the plugin in core. To do this just run the file in which you are adding plugin into preload in bun config
preload = ['./html.ts']
And in the project you can easily import HTML file and it will return as a string
import { Elysia } from "elysia";
import { html } from "@elysiajs/html";
import index from "./view/home/index.html";
import users from "./view/users/users.html";
const app = new Elysia().use(html()).get("/", () => index).get("/users", () => users).listen(3000);
console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
);
Ps. You need to configure your linters or tsconfig so that editor won't argue with problem of not finding html modules