@esbuilder/html
v0.0.6
Published
Plugin that simplifies creation of HTML files to serve your esbuild bundles
Downloads
1,230
Readme
TOC
Usage
Install
# yarn
yarn add -D esbuild @esbuilder/html
# npm
npm install -D esbuild @esbuilder/html
API
import esbuild from 'esbuild'
import { html } from '@esbuilder/html'
// serve mode
await esbuild.serve(
{},
{
entryPoints: ['src/index.html'],
plugins: [
html({
// required in serve mode
serve: true,
/**
* Output filename pattern for `src` attribute in `script` tag,
* the default value is `[name].[hash]`,
* you can override it here.
*/
// entryNames: 'js/[name]',
}),
],
outdir: 'dist',
/**
* required for keeping `dist/index.html` instead of `dist/index.{hash}.html`
*/
assetNames: ['[name]'],
},
)
// build mode
await esbuild.build({
entryPoints: ['src/index.html'],
plugins: [html()],
outdir: 'dist',
assetNames: ['[name]'],
})
<!-- src/index.html -->
<!DOCTYPE html>
<html>
<head>
<!-- ... -->
</head>
<body>
<script src="index.ts"></script>
</body>
</html>
Sponsors
| 1stG | unTS | UnTS | | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | | | |
Backers
| 1stG | unTS | UnTS | | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | | | |
Changelog
Detailed changes for each release are documented in CHANGELOG.md.