@esbuild-toolbox/html-auto-include
v0.3.0
Published
A utility that include automatically entrypoints reference to HTML passed.
Maintainers
Readme
HTML Auto include
@esbuild-toolbox/html-auto-include
This package provides a utility that include automatically entrypoints reference to HTML passed. By default, it will try to include index.html in the current folder.
THe plugin will scan the final build and add <script> tags to the HTML with the reference to the generated files.
It also support <link> tags for stylesheets.
Installation
npm
npm install @esbuild-toolbox/html-auto-includeyarn
yarn add @esbuild-toolbox/html-auto-includepnpm
pnpm add @esbuild-toolbox/html-auto-includeUsage
Basic usage it will search for index.html in the current folder and add the reference to the generated files.
import { htmlAutoIncludePlugin } from '@esbuild-toolbox/html-auto-include';
esbuild.build({
plugins: [htmlAutoIncludePlugin()],
});You can also pass a custom HTML file to include references to.
esbuild.build({
plugins: [htmlAutoIncludePlugin({ html: 'path/to/index.html' })],
});Options
html: The path to the HTML file to include references to. Defaults toindex.htmlin the current folder.outfile: The name of the output HTML file. Defaults to the value ofhtml.pathPrefix: The path prefix to use for the generated files. Defaults to./.scriptTagAttribute: Attributes to add to the generated<script>tags. Defaults to{}.base: The base URL to use for the generated files. Defaults undefined
