Overview:
The rollup-plugin-generate-html-template is a plugin for Rollup, a JavaScript module bundler, that allows users to auto-inject the resulting Rollup bundle into an HTML template. This plugin simplifies the process of adding link and script tags for the generated bundle in the HTML file. It offers options for customizing the template and injecting variables.
Features:
- Auto-inject Bundle: The plugin automatically injects the rollup bundle into the HTML template.
- Customizable Template: Users can specify the path to the source template and the directory/file name for the generated HTML file.
- Attribute Options: The plugin allows users to define attributes for the generated bundle script tag, such as async and defer.
- Variable Injection: Users can specify variables to be replaced in the generated HTML, providing dynamic content.
Installation:
To install the rollup-plugin-generate-html-template, follow these steps:
- Install the plugin using npm:
npm install rollup-plugin-generate-html-template --save-dev
- Add the plugin to your Rollup configuration file (e.g.,
rollup.config.js):
import generateHtmlTemplate from 'rollup-plugin-generate-html-template';
export default {
// ...other Rollup config options
plugins: [
// ...other Rollup plugins
generateHtmlTemplate({
// rollup-plugin-generate-html-template options
}),
],
};
Summary:
The rollup-plugin-generate-html-template simplifies the process of injecting Rollup bundles into an HTML template. It automatically adds the necessary link and script tags for the generated bundle, and provides options for customizing the template and injecting variables. With this plugin, developers can streamline the build process and easily generate HTML files that include the Rollup bundle.