{"id":22037,"library":"rollup-plugin-generate-html-template","title":"rollup-plugin-generate-html-template","description":"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.","status":"active","version":"1.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/bengsfort/rollup-plugin-generate-html-template","tags":["javascript","rollup-plugin","bundle","injection","rollup","modules","html","template"],"install":[{"cmd":"npm install rollup-plugin-generate-html-template","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-generate-html-template","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-generate-html-template","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required; plugin works with rollup >=1.1.2","package":"rollup","optional":false}],"imports":[{"note":"ESM default import; CommonJS require works in Node but not recommended for Rollup configs.","wrong":"const htmlTemplate = require('rollup-plugin-generate-html-template')","symbol":"default","correct":"import htmlTemplate from 'rollup-plugin-generate-html-template'"},{"note":"Named export does not exist; must use default import.","wrong":"import { htmlTemplate } from 'rollup-plugin-generate-html-template'","symbol":"htmlTemplate","correct":"import htmlTemplate from 'rollup-plugin-generate-html-template'"},{"note":"The function is called directly; there is no static .template method.","wrong":"import htmlTemplate from 'rollup-plugin-generate-html-template';\nhtmlTemplate.template({ template: 'src/template.html' })","symbol":"htmlTemplate (with destructured options)","correct":"import htmlTemplate from 'rollup-plugin-generate-html-template';\nhtmlTemplate({ template: 'src/template.html', target: 'dist/index.html' })"}],"quickstart":{"code":"// rollup.config.js\nimport htmlTemplate from 'rollup-plugin-generate-html-template';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife',\n  },\n  plugins: [\n    htmlTemplate({\n      template: 'src/template.html',\n      target: 'index.html',\n    }),\n  ],\n};","lang":"typescript","description":"Basic Rollup config using the plugin to inject bundle script and link tags into an HTML template."},"warnings":[{"fix":"Update import from `import { generateHtmlTemplate } from 'rollup-plugin-generate-html-template'` to `import htmlTemplate from 'rollup-plugin-generate-html-template'`.","message":"Version 1.0.0 changed the import from a named export to a default export.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"If you relied on the plugin failing for multiple entry points, update your configuration to handle multiple script tags.","message":"Version 1.2.0 changed the plugin to inject all entry points instead of failing; dynamic imports are not embedded.","severity":"breaking","affected_versions":"<1.2.0"},{"fix":"Use Rollup's `input` and `output` options as shown in the quickstart.","message":"The `entry` and `dest` options from Rollup 0.x are not supported; use `input` and `output`.","severity":"deprecated","affected_versions":">=0.60.0"},{"fix":"Upgrade to v1.2.0+ or ensure the output directory exists before building.","message":"The plugin does not create the output directory automatically if it does not exist for the target file.","severity":"gotcha","affected_versions":"<1.2.0"},{"fix":"Ensure your Rollup output includes a CSS file matching the JS bundle name, or configure accordingly.","message":"CSS injection only works if the bundle generates a CSS file; the plugin assumes the same base name as the JS bundle.","severity":"gotcha","affected_versions":">=1.7.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to `import htmlTemplate from 'rollup-plugin-generate-html-template'`.","cause":"Using a named import instead of default import.","error":"TypeError: htmlTemplate is not a function"},{"fix":"Create the directory manually or upgrade to v1.2.0+ which auto-creates directories.","cause":"The output directory for the target HTML file does not exist.","error":"ENOENT: no such file or directory, open ..."},{"fix":"Replace `entry: 'src/index.js'` with `input: 'src/index.js'`.","cause":"Using old `entry` option instead of `input`.","error":"Error: Could not resolve entry module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}