rollup-plugin-generate-html

raw JSON →
0.2.0 verified Mon Apr 27 auth: no javascript abandoned

Rollup plugin to generate an HTML file that includes the bundle script. Works with Rollup's output to insert script tags into a template, optionally inline the bundle. Version 0.2.0 targets Node >=8.3. Abandoned – last commit in 2019, no releases since. Simpler than rollup-plugin-html but lacks features like asset injection or multi-page support.

error Error: Could not resolve 'template' option
cause Template file path is incorrect or file does not exist.
fix
Ensure the template path is correct and accessible from the current working directory. Use an absolute path.
error TypeError: generateHtml is not a function
cause Importing wrong symbol; plugin exports default only.
fix
Use import generateHtml from 'rollup-plugin-generate-html' (default import).
error Cannot find module 'rollup-plugin-generate-html'
cause Package not installed or import path incorrect.
fix
Run npm install -D rollup-plugin-generate-html and ensure package.json includes it.
error Error: Failed to generate HTML: output option must be a single file
cause Plugin requires output.file to be set, not output.dir.
fix
Set output.file to a single bundle file; this plugin does not support code splitting.
gotcha The plugin generates HTML after the bundle is written, requiring the output file to be present. Ensure output.file is set, not output.dir.
fix Set output.file to a single file; plugin does not support code splitting or multiple outputs.
gotcha The inline option does not support code splitting; all chunks are inlined into a single script tag. May cause issues with dynamic imports.
fix Avoid inline with dynamic imports or use with simple IIFE bundles.
gotcha The template option expects a path to a file relative to the current working directory, not relative to the config file. Absolute paths recommended.
fix Use path.resolve(__dirname, 'template.html') for robust path resolution.
deprecated The plugin is effectively abandoned; no updates since 2019. May not work with Rollup >=2.x (uses deprecated plugin API).
fix Consider alternatives like @rollup/plugin-html or rollup-plugin-html2.
npm install rollup-plugin-generate-html
yarn add rollup-plugin-generate-html
pnpm add rollup-plugin-generate-html

Basic setup to generate an HTML file that includes the bundle script via Rollup.

// rollup.config.js
import generateHtml from 'rollup-plugin-generate-html'

export default {
  input: 'src/index.js',
  output: { file: 'dist/bundle.js', format: 'iife' },
  plugins: [
    generateHtml({
      filename: 'dist/index.html'
    })
  ]
}