Rollup plugin that automatically injects script and link tags for the final bundle into an HTML template. Current stable version is 1.7.0, with a low release cadence (last release in 2020). It simplifies HTML generation by inserting a <script> tag before </body> and a <link> tag before </head> based on the bundle output. Supports CSS injection, custom attributes, and variable replacement. Unlike more complex alternatives like rollup-plugin-html or @rollup/plugin-html, this focuses on template injection with minimal configuration.
npm install rollup-plugin-generate-html-templateVerified import paths — ran on the pinned version, not inferred.
Basic Rollup config using the plugin to inject bundle script and link tags into an HTML template.
Update import from `import { generateHtmlTemplate } from 'rollup-plugin-generate-html-template'` to `import htmlTemplate from 'rollup-plugin-generate-html-template'`.If you relied on the plugin failing for multiple entry points, update your configuration to handle multiple script tags.
Use Rollup's `input` and `output` options as shown in the quickstart.
Upgrade to v1.2.0+ or ensure the output directory exists before building.
Ensure your Rollup output includes a CSS file matching the JS bundle name, or configure accordingly.
Change to `import htmlTemplate from 'rollup-plugin-generate-html-template'`.
Create the directory manually or upgrade to v1.2.0+ which auto-creates directories.
Replace `entry: 'src/index.js'` with `input: 'src/index.js'`.