# htmelt

> Bundle your HTML assets with Esbuild and LightningCSS. Custom plugins, HMR platform, and more.

Latest version **0.5.0** (published 2024-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install htmelt
pnpm add htmelt
yarn add htmelt
bun add htmelt
```

Provides the command `htmelt`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2024-04-20 |
| First published | 2023-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 32 |
| Unpacked size | 108.7 KB |
| Known vulnerabilities | 0 (+4 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alec Larson |
| Maintainers | aleclarson |
| Keywords | html, bundler, typescript, esbuild, web-ext, plugins, extensible, extendible, lightningcss, vite |

## Links

- npm: https://www.npmjs.com/package/htmelt
- Repository: https://github.com/alloc/htmelt
- Issues: https://github.com/alloc/htmelt/issues
- npm.io page: https://npm.io/package/htmelt

## Dependencies (32)

- [ws](https://npm.io/package/ws.md) ^8.16.0
- [cac](https://npm.io/package/cac.md) ^6.7.14
- [glob](https://npm.io/package/glob.md) ^8.1.0
- [mitt](https://npm.io/package/mitt.md) ^3.0.1
- [nebu](https://npm.io/package/nebu.md) ^2.4.5
- [uuid](https://npm.io/package/uuid.md) npm:@lukeed/uuid@^2.0.1
- [execa](https://npm.io/package/execa.md) ^7.2.0
- [kleur](https://npm.io/package/kleur.md) ^4.1.5
- [dotenv](https://npm.io/package/dotenv.md) ^16.4.5
- [mrmime](https://npm.io/package/mrmime.md) ^1.0.1
- [esbuild](https://npm.io/package/esbuild.md) ^0.17.19
- [meriyah](https://npm.io/package/meriyah.md) ^4.4.2
- [chokidar](https://npm.io/package/chokidar.md) ^3.6.0
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.3.2
- [type-fest](https://npm.io/package/type-fest.md) ^3.13.1
- [node-forge](https://npm.io/package/node-forge.md) ^1.3.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.24.4
- [ts-debounce](https://npm.io/package/ts-debounce.md) ^4.0.0
- [browserslist](https://npm.io/package/browserslist.md) ^4.23.0
- [lightningcss](https://npm.io/package/lightningcss.md) ^1.24.1
- [esbuild-extra](https://npm.io/package/esbuild-extra.md) ^0.4.0
- [@htmelt/plugin](https://npm.io/package/@htmelt/plugin.md) ^0.5.1
- [builtin-modules](https://npm.io/package/builtin-modules.md) ^3.3.0
- [mini-svg-data-uri](https://npm.io/package/mini-svg-data-uri.md) ^1.4.4
- [convert-source-map](https://npm.io/package/convert-source-map.md) ^2.0.0
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.21
- [@chialab/estransform](https://npm.io/package/@chialab/estransform.md) ^0.17.5
- [html-minifier-terser](https://npm.io/package/html-minifier-terser.md) ^7.2.0
- [serialize-javascript](https://npm.io/package/serialize-javascript.md) ^6.0.2
- [@ampproject/remapping](https://npm.io/package/@ampproject/remapping.md) ^2.3.0
- [@chialab/node-resolve](https://npm.io/package/@chialab/node-resolve.md) ^0.17.1
- [browserslist-to-esbuild](https://npm.io/package/browserslist-to-esbuild.md) ^1.2.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2024-04-20
- 0.4.6 — 2024-02-23
- 0.4.5 — 2024-02-23
- 0.4.4 — 2023-06-06
- 0.4.3 — 2023-05-18
- 0.4.2 — 2023-05-18
- 0.4.1 — 2023-05-18
- 0.4.0 — 2023-05-13
- 0.3.0 — 2023-05-08
- 0.2.4 — 2023-05-05
- 0.2.3 — 2023-05-02
- 0.2.2 — 2023-04-27
- 0.2.1 — 2023-04-22
- 0.2.0 — 2023-04-18
- 0.1.6 — 2023-04-17
- … 4 more at https://npm.io/package/htmelt/versions

## README

# htmelt

Experimental bundler for HTML, powered by ESBuild and LightningCSS. It
"melts" (hence the name htmelt) any CSS and JS found in your HTML files
into CSS/JS bundles.

<sub>You should probably just use Vite.</sub>

### Features

- custom plugins with the `bundle.config.js` file
- ESBuild integration (TypeScript + ESM syntax, code splitting, dynamic imports)
- LightningCSS integration
- Browserslist integration
- HTML entry point scanning
- JS/CSS bundling
- `import.meta.glob` support
- worker bundling with `new URL('./worker.ts', import.meta.url)`
- great for [Web Extension](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions) development
  - dev server for painless extension reloading
  - run multiple browsers at once (or use `--webext=chromium` to only run Chrome)
- `--watch` mode
  - CSS hot reloading
  - HTML rebuild on JS/HTML changes
  - sets `NODE_ENV=development`
- default mode
  - HTML/JS/CSS minification
  - sets `NODE_ENV=production`

### Usage

Before running `htmelt`, you should move your HTML files into the `src/` directory and use relative paths for JS/CSS references inside your HTML files.

```sh
# Run in development mode
pnpm htmelt --watch

# Run in production mode
pnpm htmelt
```

If you want TypeScript to recognize `import.meta.glob` calls, you can add the following to your `tsconfig.json` file.

```json
{
  "compilerOptions": {
    "lib": ["esnext"],
    "types": ["htmelt/client.d.ts"]
  }
}
```

### Configuration

The `bundle.config.js` file allows for customization.

```js
export default {
  // Browserslist targets.
  targets: ['defaults', 'not IE 11'],
  // Input and output directories.
  src: './src',
  build: './build',
  // Tool-specific options.
  esbuild: {...},
  lightningcss: {...},
  // If true, will delete the build directory before building.
  deletePrev: false,
}
```

---
_Source: https://npm.io/package/htmelt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
