A Vite plugin to generate separate output files for JavaScript and CSS bundles with customizable attributes.
npm install vite-plugin-generate-htmlThis plugin allows you to define separate output files for JavaScript and CSS bundles. It generates and elements from entry files and writes them to specified output files.
This is particularly useful when:
- Your bundles include a hash in the filename that changes with every compilation.
- You have multiple views that need to include these JS and CSS bundles.
- You want to output files in formats like .html, .cshtml (Razor), .php, etc.
Inspired by Webpack's HtmlWebpackPlugin, this plugin provides similar functionality for Vite.
---
Install the plugin using npm:
``bash`
npm install --save-dev vite-plugin-generate-html
---
The plugin accepts the following configuration options:
`ts
{
/**
* Directory to serve as plain static assets.
* @default "/dist/"
*/
publicDir?: string;
/**
* The file to write the generated
`
#### css.html
`html`
> Note: The plugin will overwrite the contents of the specified output files.
---
You can define custom attributes for