Registry / web-framework / vite-plugin-generate-html

vite-plugin-generate-html

JSON →
library0.2.3jsnpmunverified

A Vite plugin (v0.2.3) that generates separate HTML files containing <script> and <link> tags for JavaScript and CSS bundles respectively, inspired by Webpack's HtmlWebpackPlugin. Supports custom attributes for script/link elements, multiple entry points, and filtering via 'chunks'. Ideal for projects needing dynamic injection of hashed bundle references into views like .cshtml or .php. Ships TypeScript types. Released infrequently (last update Nov 2022). Differentiator: lightweight and focused on generating only the tags, not a full HTML page.

npm install vite-plugin-generate-html
INSTALL
IMPORT
SIG · VITE-PLUGIN-GENERA
V
vite-plugin-generate-html
web-frameworkjavascriptv0.2.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'
import { VitePluginGenerateHtmlFiles } from 'vite-plugin-generate-html'
Default export only; named export does not exist.
VitePluginGenerateHtmlFiles
import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'
const VitePluginGenerateHtmlFiles = require('vite-plugin-generate-html')
ESM-only; CJS require will fail.

Basic setup: generates separate HTML files for JS and CSS bundle references, using default attributes.

import { resolve as pathResolve } from 'path'; import { defineConfig } from 'vite'; import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'; export default defineConfig({ build: { rollupOptions: { input: { app: pathResolve(__dirname, 'src/main.ts'), }, }, }, plugins: [ VitePluginGenerateHtmlFiles({ publicDir: '/dist/', jsEntryFile: pathResolve(__dirname, '../some/dir/javascript.html'), cssEntryFile: pathResolve(__dirname, '../some/dir/css.html'), }), ], });
Debug
Known issues
gotchaIf `output` is used, all entry points must be defined in the output array unless filtered with `chunks`.
fix
Define an output entry for each entry point or use the `chunks` parameter to limit which entries are processed.
affects: >=0.2.0
gotchaThe plugin does not generate a full HTML file; it only writes <script> and <link> tags to the specified files.
fix
Integrate the generated tags into your own HTML template or server-side view.
affects: >=0.0.0
breakingIn v0.2.0, the plugin changed to support multiple entry points; the `output` parameter was introduced and the single file parameters changed.
fix
Update configuration: if using multiple entries, use `output` array and `chunks` filter.
affects: >=0.2.0
deprecatedNo deprecations reported.
fix
N/A
affects: none
Errors
Common errors & fixes
Cannot find module 'vite-plugin-generate-html'
Package not installed or incorrect import path.
fix
Run `npm install --save-dev vite-plugin-generate-html` and use correct import statement.
TypeError: VitePluginGenerateHtmlFiles is not a function
Using named import instead of default import.
fix
Use `import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'` (no curly braces).
Error: [vite-plugin-generate-html] The 'output' parameter must be an array when specified.
Providing `output` as an object instead of an array.
fix
Wrap the output object in an array: `output: [{ main: { attrs: [...], linkAttrs: [...] } }]`
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
viterequiredVite plugin, requires Vite's build system
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
vite-plugin-generate-html — npm install vite-plugin-generate-html · libregistry