rollup-plugin-html-scaffold
raw JSON → 0.2.0 verified Mon Apr 27 auth: no javascript
Rollup plugin for generating HTML files from templates with placeholder injection. Current stable version: 0.2.0. Low release cadence (last release Feb 2019). Replaces simple HTML template processing within Rollup builds, allowing dynamic substitution of placeholders like <%= appName %>. Compared to alternatives like @rollup/plugin-html or html-webpack-plugin, this plugin offers minimalistic template support without additional features like asset hashing or minification. Requires Rollup >=1.1.2.
Common errors
error Error: Cannot find module 'rollup-plugin-html-scaffold' ↓
cause The package is not installed or not present in node_modules.
fix
Run 'npm install rollup-plugin-html-scaffold --save-dev' or 'yarn add rollup-plugin-html-scaffold --dev'.
error TypeError: html is not a function ↓
cause Wrong import style: using named import instead of default import.
fix
Change to 'import html from 'rollup-plugin-html-scaffold'' (default import) or use 'const html = require('rollup-plugin-html-scaffold').default'.
error Error: Input HTML file not found: src/index.html ↓
cause The 'input' option path is incorrect or file doesn't exist.
fix
Verify that 'input' points to an existing HTML file relative to the project root.
Warnings
gotcha The plugin does not handle Rollup's asset emission. Generated HTML file is written directly to disk, not through Rollup's output system. This can cause issues if output directory is cleaned or if multiple outputs are used. ↓
fix Ensure the output path is relative to project root, and consider using @rollup/plugin-html or rollup-plugin-generate-html for better integration.
gotcha Template placeholders use ERB-style delimiters (<%= %>). If your HTML contains similar patterns (e.g., in JS templates), they will be incorrectly parsed. ↓
fix Escape literal '<%=' sequences by using a placeholder like '<%=' in the template or choose a different plugin.
deprecated The package has not been updated since February 2019 and uses outdated Rollup plugin API (pre-2.0). It may not work with Rollup 3+. ↓
fix Upgrade to Rollup 2 last supported version or switch to maintained alternatives like @rollup/plugin-html or rollup-plugin-html2.
gotcha The plugin does not minify or inject hashed filenames. For production, you need additional plugins or manual configuration. ↓
fix Use rollup-plugin-replace or @rollup/plugin-replace to inject hashed filenames, or choose a more feature-rich HTML plugin.
Install
npm install rollup-plugin-html-scaffold yarn add rollup-plugin-html-scaffold pnpm add rollup-plugin-html-scaffold Imports
- default wrong
import { html } from 'rollup-plugin-html-scaffold'correctimport html from 'rollup-plugin-html-scaffold' - default wrong
const html = require('rollup-plugin-html-scaffold')correctconst html = require('rollup-plugin-html-scaffold').default - HtmlOptions
import type { HtmlOptions } from 'rollup-plugin-html-scaffold'
Quickstart
// rollup.config.js
import html from 'rollup-plugin-html-scaffold';
import { defineConfig } from 'rollup';
export default defineConfig({
input: 'src/index.js',
output: {
dir: 'dist',
format: 'es',
},
plugins: [
html({
input: 'src/index.html',
output: 'dist/index.html',
template: {
'title': 'My App',
'bundle': 'bundle.js',
},
}),
],
});
// src/index.html
<!doctype html><html><head><title><%= title %></title></head><body><script src="<%= bundle %>"></script></body></html>