{"id":22061,"library":"rollup-plugin-html2","title":"rollup-plugin-html2","description":"Rollup plugin to inject bundled JavaScript/CSS files into an HTML template. Current stable version is 4.0.0. It reads output from Rollup's bundle rather than scanning the file system, and emits the HTML as an asset for other plugins to use. Supports customization via template, filename, title, meta tags, and asset injection order. Requires Rollup >=3.0 and has an optional peer dependency on html-minifier. Licensed under MIT.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/mentaljam/rollup-plugin-html2","tags":["javascript","rollup","plugin","html"],"install":[{"cmd":"npm install rollup-plugin-html2","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-html2","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-html2","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: required to work as a Rollup plugin","package":"rollup","optional":false},{"reason":"optional peer dependency for TypeScript users","package":"@types/html-minifier","optional":true}],"imports":[{"note":"Default export, not named.","wrong":"import { html2 } from 'rollup-plugin-html2'","symbol":"html2","correct":"import html2 from 'rollup-plugin-html2'"},{"note":"For CJS via require, use default import pattern.","wrong":"const { html2 } = require('rollup-plugin-html2')","symbol":"default","correct":"const html2 = require('rollup-plugin-html2')"},{"note":"Type import only, not a runtime value.","wrong":"import { PluginOptions } from 'rollup-plugin-html2'","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'rollup-plugin-html2'"}],"quickstart":{"code":"import html2 from 'rollup-plugin-html2';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es',\n  },\n  plugins: [\n    html2({\n      template: 'src/template.html',\n      filename: 'index.html',\n      title: 'My App',\n    }),\n  ],\n};","lang":"javascript","description":"Shows basic integration: import the default export and use it in a Rollup config with a custom template and output filename."},"warnings":[{"fix":"Update templates to not expect a leading slash in asset paths.","message":"Version 2.0.0 stopped prefixing file paths with '/'","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Rollup to version 3 or later.","message":"Version 3.0.0 requires Rollup >=3.0","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Reorder plugins: favicons first, then html2.","message":"rollup-plugin-favicons must be placed before rollup-plugin-html2 in plugins array","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Replace `inject: true` with `inject: 'head'` and `hash: true` with a custom filename pattern.","message":"Options `inject` and `hash` are deprecated; use `fileName` and `publicPath` instead","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Upgrade Rollup to version 3 or higher, or downgrade rollup-plugin-html2 to v2.x.","cause":"Using rollup-plugin-html2 version >=3.0.0 with an older Rollup version","error":"Error: The plugin 'rollup-plugin-html2' is not compatible with Rollup <3.0"},{"fix":"Use `import html2 from 'rollup-plugin-html2'` (default import) instead of `import { html2 } from 'rollup-plugin-html2'`.","cause":"Importing as a named export instead of default export","error":"TypeError: html2 is not a function"},{"fix":"Run `npm i -D rollup-plugin-html2` and ensure using the correct import (default import for ESM or `const html2 = require('rollup-plugin-html2')` for CJS).","cause":"Package not installed or imported incorrectly in a CommonJS context","error":"Error: Could not resolve 'rollup-plugin-html2'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}