Vite plugin that simplifies creation of HTML files as entry points for Vite builds, similar to webpack's html-webpack-plugin. Version 2.0.2 is the latest stable release, with monthly releases. It allows developers to explicitly set script entry files (e.g., ./src/main.ts) without relying on Vite's default index.html parsing. Supports minification via html-minifier-terser, custom templates, and entry signature preservation for Rollup. Unlike Vite's default index.html approach, it provides explicit control over the entry file and output HTML filename, making it suitable for non-library mode builds.
npm install vite-plugin-index-htmlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin with common options: custom entry, template, output filename, minification, and entry signature preservation.
Set entry: './src/main.ts' in plugin options.
Upgrade Node.js to >=14.
Use Vite's 'base' option instead of 'publicPath'.
Conditionally add the plugin only when build.lib is not defined.
Use type assertion or import the Options type for proper type checking.
Pass a valid entry path, e.g., 'entry: "./src/main.ts"'.
Use 'import htmlPlugin from 'vite-plugin-index-html'' (default import).
Verify the 'template' option points to an existing HTML file, or omit it to use the default.