Gathering detailed insights and metrics for @rollup/plugin-html
Gathering detailed insights and metrics for @rollup/plugin-html
Gathering detailed insights and metrics for @rollup/plugin-html
Gathering detailed insights and metrics for @rollup/plugin-html
@web/rollup-plugin-html
Rollup plugin for bundling HTML files
rollup-plugin-html
HTML import plugin for rollup
rollup-plugin-minify-html-literals
Rollup plugin to minify HTML template literal strings
rollup-plugin-generate-html-template
Rollup plugin for automatically injecting a script tag with the final bundle into an html file.
🍣 The one-stop shop for official Rollup plugins
npm install @rollup/plugin-html
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (75.16%)
TypeScript (24.83%)
Shell (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3,713 Stars
1,228 Commits
604 Forks
35 Watchers
6 Branches
270 Contributors
Updated on Jul 10, 2025
Latest Version
1.1.0
Package Id
@rollup/plugin-html@1.1.0
Unpacked Size
19.17 kB
Size
5.19 kB
File Count
8
NPM Version
10.8.2
Node Version
20.18.1
Published on
Dec 15, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
🍣 A Rollup plugin which creates HTML files to serve Rollup bundles.
Please see Supported Output Formats for information about using this plugin with output formats other than esm
(es
), iife
, and umd
.
This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.
Using npm:
1npm install @rollup/plugin-html --save-dev
Create a rollup.config.js
configuration file and import the plugin:
1const html = require('@rollup/plugin-html'); 2 3module.exports = { 4 input: 'src/index.js', 5 output: { 6 dir: 'output', 7 format: 'cjs' 8 }, 9 plugins: [html()] 10};
Then call rollup
either via the CLI or the API.
Once run successfully, an HTML file should be written to the bundle output destination.
addScriptsToHead
Type: Boolean
Default: false
Place scripts in the <head>
tag instead of <body>
.
attributes
Type: Object
Default: { html: { lang: 'en' }, link: null, script: null }
Specifies additional attributes for html
, link
, and script
elements. For each property, provide an object with key-value pairs that represent an HTML element attribute name and value. By default, the html
element is rendered with an attribute of lang="en"
.
Note: If using the es
/ esm
output format, { type: 'module'}
is automatically added to attributes.script
.
fileName
Type: String
Default: 'index.html'
meta
Type: Array[...object]
Default: [{ charset: 'utf-8' }]
Specifies attributes used to create <meta>
elements. For each array item, provide an object with key-value pairs that represent <meta>
element attribute names and values.
Specifies the name of the HTML to emit.
publicPath
Type: String
Default: ''
Specifies a path to prepend to all bundle assets (files) in the HTML output.
template
Type: Function
Default: internal function
Returns: String
Specifies a function that provides the rendered source for the HTML output. The function should be in the form of:
1const template = ({ attributes, bundle, files, publicPath, title }) => { ... }
attributes
: Corresponds to the attributes
option passed to the pluginbundle
: An Object
containing key-value pairs of AssetInfo
or ChunkInfo
files
: An Array
of AssetInfo
or ChunkInfo
containing any entry (isEntry: true
) files, and any asset (isAsset: true
) files in the bundle that will be emittedpublicPath
: Corresponds to the publicPath
option passed to the plugintitle
: Corresponds to the title
option passed to the pluginBy default this is handled internally and produces HTML in the following format:
1<!DOCTYPE html> 2<html ${attributes}> 3 <head> 4 ${metas} 5 <title>${title}</title> 6 ${links} 7 </head> 8 <body> 9 ${scripts} 10 </body> 11</html>
Where ${links}
represents all <link ..
tags for CSS and ${scripts}
represents all <script...
tags for JavaScript files.
title
Type: String
Default: 'Rollup Bundle'
Specifies the HTML document title.
makeHtmlAttributes(attributes)
Parameters: attributes
, Type: Object
Returns: String
Consumes an object with key-value pairs that represent an HTML element attribute name and value. The function returns all pairs as a space-separated string of valid HTML element attributes. e.g.
1const { makeHtmlAttributes } = require('@rollup/plugin-html'); 2 3makeHtmlAttributes({ lang: 'en', 'data-batcave': 'secret' }); 4// -> 'lang="en" data-batcave="secret"'
By default, this plugin supports the esm
(es
), iife
, and umd
output formats, as those are most commonly used as browser bundles. Other formats can be used, but will require using the template
option to specify a custom template function which renders the unique requirements of other formats.
amd
Will likely require use of RequireJS semantics, which allows only for a single entry <script>
tag. If more entry chunks are emitted, these need to be loaded via a proxy file. RequireJS would also need to be a dependency and added to the build: https://requirejs.org/docs/start.html.
system
Would require a separate <script>
tag first that adds the s.js
minimal loader. Loading modules might then resemble: <script>System.import('./batman.js')</script>
.
This plugin was inspired by and is based upon mini-html-webpack-plugin by Juho Vepsäläinen and Artem Sapegin, with permission.
No vulnerabilities found.
Reason
12 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 14/30 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More