Gathering detailed insights and metrics for rollup-plugin-index-html
Gathering detailed insights and metrics for rollup-plugin-index-html
Gathering detailed insights and metrics for rollup-plugin-index-html
Gathering detailed insights and metrics for rollup-plugin-index-html
Open Web Components: guides, tools and libraries for developing web components.
npm install rollup-plugin-index-html
Typescript
Module System
Node Version
NPM Version
eslint-plugin-lit-a11y@5.1.0
Updated on Jun 28, 2025
@open-wc/dedupe-mixin@2.0.1
Updated on Jun 25, 2025
eslint-plugin-lit-a11y@5.0.1
Updated on Jun 09, 2025
eslint-plugin-lit-a11y@5.0.0
Updated on Jun 04, 2025
@open-wc/eslint-config@13.0.0
Updated on Jun 04, 2025
eslint-plugin-lit-a11y@4.1.4
Updated on Jul 11, 2024
JavaScript (95.74%)
TypeScript (2.45%)
HTML (1.68%)
MDX (0.12%)
Shell (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,329 Stars
2,581 Commits
426 Forks
46 Watchers
85 Branches
225 Contributors
Updated on Jul 11, 2025
Latest Version
1.12.8
Package Id
rollup-plugin-index-html@1.12.8
Size
9.80 kB
NPM Version
lerna/3.4.3/node@v10.16.0+x64 (linux)
Node Version
10.16.0
Published on
Oct 11, 2020
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
WARNING: This project is deprecated and no longer maintained. See @open-wc/rollup-plugin-html and @open-wc/rollup-plugin-polyfills-loader for replacements.
Rollup plugin to make rollup understand your index.html.
Part of Open Web Components: guides, tools and libraries for modern web development and web components
1<html lang="en-GB"> 2 <head> 3 <title>My app</title> 4 <style> 5 my-app { 6 display: block; 7 } 8 </style> 9 </head> 10 11 <body> 12 <h1> 13 <span> 14 Hello world! 15 </span> 16 </h1> 17 <my-app></my-app> 18 19 <script> 20 (function () { 21 var message = 'hello inline script'; 22 console.log(message); 23 })(); 24 </script> 25 26 <script type="module" src="./app.js"></script> 27 </body> 28</html>
Extracts any <script type="module" src="...">
and feeds them to rollup as entry point(s)
Outputs the same index.html with updated file hashes and all inline HTML, CSS and JS minified:
1<html lang="en-GB"> 2 <head> 3 <title>My app</title> 4 <style> 5 my-app { 6 display: block; 7 } 8 </style> 9 </head> 10 <body> 11 <h1><span>Hello world!</span></h1> 12 <my-app></my-app> 13 <script> 14 console.log('hello inline script'); 15 </script> 16 <script src="app.202933f045cc9f6cdf51.js"></script> 17 </body> 18</html>
Note that only module scripts with a src
attribute are used as entrypoints, regular scripts and inline modules are minified but not parsed by rollup.
To use this plugin, add it to your rollup configuration and set your index.html as entrypoint:
1const path = require('path'); 2const indexHTML = require('rollup-plugin-index-html'); 3 4module.exports = { 5 input: path.resolve(__dirname, './index.html'), 6 plugins: [indexHTML(config)], 7};
Note when using
@open-wc/building-rollup
many polyfills are already configured for you.
Depending on which browser you need to support you may need to polyfill certain browser features. To keep your bundles small, we don't serve any polyfills by default. You can enable polyfills in the configuration.
When enabling polyfills a small loader script is injected to your index.html. Polyfills are loaded based on feature detection. This causes a small delay in loading your app. We mediate this by adding a preload link during the build.
To enable polyfills:
1indexHTML({ 2 polyfills: { 3 coreJs: true, 4 regeneratorRuntime: true, 5 webcomponents: true, 6 fetch: true, 7 intersectionObserver: true, 8 }, 9});
core-js
polyfills many language features such as Promise
, Symbol
and String.prototype.includes
. regeneratorRuntime
is necessary when you compile async await
code which is transpiled to javascript ES5. These two polyfills are mainly for supporting legacy browsers. They are only loaded on browsers which don't support modules, such as IE11.
The rest of the polyfills target specific browser features, see their documentation for more info:
If you need a polyfill which is not on this list, consider creating an issue so that we can add it. You can also specify custom polyfills:
1indexHTML({
2 polyfills: {
3 coreJs: true,
4 customPolyfills: [
5 {
6 // the name of your polyfill
7 name: 'my-feature',
8 // expression which is run in the browser to determine if the polyfill should be loaded
9 test: "'myFeature' in window",
10 // path to your polyfill
11 path: require.resolve('my-feature-polyfill/dist/bundled.js'),
12 // path to the sourcemaps of your polyfill. optional
13 sourcemapPath: require.resolve('my-feature-polyfill/dist/bundled.js.map'),
14 },
15 ],
16 },
17});
Note when using
@open-wc/building-rollup/modern-and-legacy-config
the multi build is already configured for you
If you need to support non-modern browsers, such IE11 or older versions of chrome, safari and firefox, it's better to create multiple builds of your app.
You can make one build for modern browsers using modern syntax and features, and one build for legacy browsers compiled to javascript ES5 and with more polyfills loaded. This way you don't penalize all your users for your lowest browser target.
To create multiple rollup builds, export an array of rollup configs instead of a single config. Set the multiBuild
option in both instances of the plugin and set legacy
option in the legacy build:
1const path = require('path'); 2const indexHTML = require('rollup-plugin-index-html'); 3 4module.exports = [ 5 { 6 entry: path.resolve(__dirname, './index.html'), 7 plugins: [ 8 indexHTML({ 9 multiBuild: true, 10 polyfills: { 11 coreJs: true, 12 regeneratorRuntime: true, 13 webcomponents: true, 14 }, 15 }), 16 ], 17 }, 18 19 { 20 entry: path.resolve(__dirname, './index.html'), 21 module: { 22 rules: [ 23 // Note: You will probably also want to configure babel for the legacy build. 24 // this is not a complete example, you will need to add more configuration for babel 25 { test: /\.js/, use: { loader: 'babel-loader' } }, 26 ], 27 }, 28 plugins: [ 29 indexHTML({ 30 multiBuild: true, 31 legacy: true, 32 }), 33 ], 34 }, 35];
For the legacy build you do not need to configure any polyfills, as these are already injected by the modern build.
You will probably need to use babel as well to transpile your code to ES5. Remember to change the browser targets for the modern and legacy build accordingly. For example latest 2 of the major browsers for modern and IE11 for the legac build.
We use html-minifier for minifcation with a default configuration. You can adjust this configuration by passing a minify object:
1indexHTML({ 2 minify: { 3 // minify options 4 }, 5});
The options object is passed as is to html-minifier
. See the documentation of html-minifier for all possible minification options.
It is also possible to turn off minification completely by passing minify:
1indexHTML({ 2 minify: false, 3});
You can use this plugin without an index.html plugin if you still want to make use of the polyfilling features. You can do this by adding a custom template function:
1const path = require('path'); 2const indexHTML = require('rollup-plugin-index-html'); 3 4module.exports = { 5 entry: path.resolve(__dirname, './my-app.js'), 6 7 output: { 8 filename: '[name].[chunkhash].js', 9 chunkFilename: '[name].[chunkhash].js', 10 }, 11 12 plugins: [ 13 indexHTML({ 14 template: ({ assets, entries, legacyEntries, variation }) => ` 15 <html> 16 <head></head> 17 <body></body> 18 </html> 19 `, 20 }), 21 ], 22};
When loading polyfills we inject a small script in your index.html. If you need CSP you can separate the script in a separate file:
1const path = require('path'); 2const indexHTML = require('rollup-plugin-index-html'); 3 4module.exports = { 5 entry: path.resolve(__dirname, './my-app.js'), 6 7 output: { 8 filename: '[name].[chunkhash].js', 9 chunkFilename: '[name].[chunkhash].js', 10 }, 11 12 plugins: [ 13 indexHTML({ 14 polyfills: { 15 webcomponents: true, 16 }, 17 loader: 'external', 18 }), 19 ], 20};
The template function receives the project's assets
and entries
. If applicable it also receives the legacyEntries
and variation
.
No vulnerabilities found.
Reason
16 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
Found 13/21 approved changesets -- score normalized to 6
Reason
dependency not pinned by hash detected -- score normalized to 6
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
55 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