@xbuildr/html
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

esbuild HTML Plugin

Plugin that simplifies creation of HTML files to serve your esbuild bundles.

TOC

Usage

Install

# yarn
yarn add -D esbuild @xbuildr/html

# npm
npm install -D esbuild @xbuildr/html

API

import esbuild from 'esbuild'
import { html } from '@xbuildr/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 RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Backers

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

Readme

Keywords

none

Package Sidebar

Install

npm i @xbuildr/html

Weekly Downloads

1

Version

0.0.0

License

MIT

Unpacked Size

17.5 kB

Total Files

11

Last publish

Collaborators

  • jounqin