{"id":22672,"library":"vite-plugin-generate-html","title":"vite-plugin-generate-html","description":"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.","status":"active","version":"0.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/gedouu/vite-plugin-generate-html","tags":["javascript","vite-plugin","vite","generate-html","generate-bundle","html-link","html-script","rollup","rollup-plugin","typescript"],"install":[{"cmd":"npm install vite-plugin-generate-html","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-generate-html","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-generate-html","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Vite plugin, requires Vite's build system","package":"vite","optional":false}],"imports":[{"note":"Default export only; named export does not exist.","wrong":"import { VitePluginGenerateHtmlFiles } from 'vite-plugin-generate-html'","symbol":"default","correct":"import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'"},{"note":"ESM-only; CJS require will fail.","wrong":"const VitePluginGenerateHtmlFiles = require('vite-plugin-generate-html')","symbol":"VitePluginGenerateHtmlFiles","correct":"import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'"}],"quickstart":{"code":"import { resolve as pathResolve } from 'path';\nimport { defineConfig } from 'vite';\nimport VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html';\n\nexport default defineConfig({\n  build: {\n    rollupOptions: {\n      input: {\n        app: pathResolve(__dirname, 'src/main.ts'),\n      },\n    },\n  },\n  plugins: [\n    VitePluginGenerateHtmlFiles({\n      publicDir: '/dist/',\n      jsEntryFile: pathResolve(__dirname, '../some/dir/javascript.html'),\n      cssEntryFile: pathResolve(__dirname, '../some/dir/css.html'),\n    }),\n  ],\n});","lang":"typescript","description":"Basic setup: generates separate HTML files for JS and CSS bundle references, using default attributes."},"warnings":[{"fix":"Define an output entry for each entry point or use the `chunks` parameter to limit which entries are processed.","message":"If `output` is used, all entry points must be defined in the output array unless filtered with `chunks`.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Integrate the generated tags into your own HTML template or server-side view.","message":"The plugin does not generate a full HTML file; it only writes <script> and <link> tags to the specified files.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update configuration: if using multiple entries, use `output` array and `chunks` filter.","message":"In v0.2.0, the plugin changed to support multiple entry points; the `output` parameter was introduced and the single file parameters changed.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"N/A","message":"No deprecations reported.","severity":"deprecated","affected_versions":"none"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev vite-plugin-generate-html` and use correct import statement.","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'vite-plugin-generate-html'"},{"fix":"Use `import VitePluginGenerateHtmlFiles from 'vite-plugin-generate-html'` (no curly braces).","cause":"Using named import instead of default import.","error":"TypeError: VitePluginGenerateHtmlFiles is not a function"},{"fix":"Wrap the output object in an array: `output: [{ main: { attrs: [...], linkAttrs: [...] } }]`","cause":"Providing `output` as an object instead of an array.","error":"Error: [vite-plugin-generate-html] The 'output' parameter must be an array when specified."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}