Skip to content

damonsmith/bun-plugin-inline-templates

Repository files navigation

Bun Plugin for HTML

The bun-plugin-inline-templates is a plugin for the Bun build tool that replaces any <link rel="import" href="something.html"> with the contents of the path in the href.

Installation

You can install bun-plugin-inline-templates using the following command:

bun add -d bun-plugin-inline-templates

Usage

To use this plugin, import it into your code and add it to the list of plugins when building your project with Bun. Here's an example:

import inlineTemplates from 'bun-plugin-inline-templates';

await Bun.build({
  entrypoints: ['./src/index.html', './src/other.html'],
  outdir: './dist',  // Specify the output directory
  plugins: [
    inlineTemplates()
  ],
});

Or if you're using it with bun-plugin-html then add it after that plugin like this:

import html from 'bun-plugin-html';
import inlineTemplates from 'bun-plugin-inline-templates';

await Bun.build({
  entrypoints: ['./src/index.html', './src/other.html'],
  outdir: './dist',  // Specify the output directory
  plugins: [
    html(),
    inlineTemplates()
  ],
});

Acknowledgements

This plugin was created by mostly copying the bun-plugin-html plugin from Bjorn at https://github.com/BjornTheProgrammer/bun-plugin-html

Massive thanks to that project, this plugin is designed to be inserted before it so that they can be used together.

License

This plugin is licensed under MIT.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published