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-htmlVerified import paths — ran on the pinned version, not inferred.
Basic setup: generates separate HTML files for JS and CSS bundle references, using default attributes.
Define an output entry for each entry point or use the `chunks` parameter to limit which entries are processed.
Integrate the generated tags into your own HTML template or server-side view.
Update configuration: if using multiple entries, use `output` array and `chunks` filter.
N/A
Run `npm install --save-dev vite-plugin-generate-html` and use correct import statement.
Use `import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'` (no curly braces).
Wrap the output object in an array: `output: [{ main: { attrs: [...], linkAttrs: [...] } }]`