Registry / web-framework / vite-plugin-htmlx

vite-plugin-htmlx

JSON →
library1.0.5jsnpmunverified

A Vite plugin for HTML processing that provides EJS templating, HTML minification, and multi-page application support. Version 1.0.5, actively maintained with recent fixes. It is a fork and alternative to the stalled vite-plugin-html, aiming to address bugs and unmerged PRs. Key differentiators: EJS templates, flexible entry/template configuration, and inject tags with precise placement control.

npm install vite-plugin-htmlx
INSTALL
IMPORT
SIG · VITE-PLUGIN-HTMLX
V
vite-plugin-htmlx
web-frameworkjavascriptv1.0.5
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (html)
✓ import html from 'vite-plugin-htmlx'
✗ const html = require('vite-plugin-htmlx')
ESM-only; CommonJS require will fail
createHtmlPlugin
✓ import { createHtmlPlugin } from 'vite-plugin-htmlx'
✗ import createHtmlPlugin from 'vite-plugin-htmlx'
Named export; also available as default export 'html'
html (default)
✓ import html from 'vite-plugin-htmlx'
✗ import { html } from 'vite-plugin-htmlx'
Default export is the function; named export is 'createHtmlPlugin'
UserOptions type
✓ import type { UserOptions } from 'vite-plugin-htmlx'
✗ import { UserOptions } from 'vite-plugin-htmlx'
UserOptions is exported as a type, not a value; use type-only import in TypeScript

Sets up vite-plugin-htmlx with HTML minification and EJS template data injection for a single-page app.

import { defineConfig } from 'vite'; import html from 'vite-plugin-htmlx'; export default defineConfig({ plugins: [ html({ minify: true, page: { entry: 'src/main.ts', inject: { data: { title: 'My App', injectScript: '<script src="./inject.js"></script>', }, }, }, }), ], });
Debug
Known issues
breakingVite version requirement changed from >=3.0.0 to >=4.0.0 in v1.0.0
fix
Upgrade Vite to 4.0.0 or later.
affects: >=1.0.0
gotchaDefault export is named 'html', not 'createHtmlPlugin'. Confusing when migrating from vite-plugin-html.
fix
Use 'import html from 'vite-plugin-htmlx'' or 'import { createHtmlPlugin } from 'vite-plugin-htmlx''.
affects: >=1.0.0
gotchaMulti-page config requires 'page' to be an array of MpaPage objects; single page uses an object.
fix
For single page, use 'page: {...}'. For multi-page, use 'page: [{...}, ...]'.
affects: >=1.0.0
deprecatedThe 'createHtmlPlugin' export is deprecated in favor of the default export 'html' since v1.0.0.
fix
Use default import 'import html from 'vite-plugin-htmlx'' instead.
affects: ==1.0.0
gotchaFilename defaults to 'index.html'. If you forget to set 'filename' for MPA pages, the last page with no filename may conflict.
fix
Always set explicit 'filename' for each MPA page entry.
affects: >=1.0.0
Errors
Common errors & fixes
Error: [plugin:vite-plugin-htmlx] The template file does not exist:
Specified template path is incorrect or file missing.
fix
Ensure 'template' path in page config points to an existing HTML file, e.g., 'public/index.html'.
Error: [vite] RollupError: ENOENT: no such file or directory, open '.../dist/index.html'
Multi-page build missing 'filename' config causing output file overwrite or missing.
fix
Provide unique 'filename' for each MPA page entry, e.g., 'index.html', 'other.html'.
TypeError: Cannot read properties of undefined (reading 'replace')
Missing 'minify' option or invalid minify config.
fix
Set minify: true or provide valid MinifyOptions object.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
viterequiredpeer dependency: requires Vite >=4.0.0
Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
vite-plugin-htmlx — npm install vite-plugin-htmlx · libregistry