Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
vite-plugin-html
Advanced tools
A plugin for vite to Minimize index.html and use lodash.template template syntax in index.html
vite-plugin-html is a plugin for Vite that allows you to inject data into your HTML files, modify HTML templates, and perform other HTML-related tasks during the build process.
Inject Data into HTML
This feature allows you to inject data into your HTML templates. In this example, the title and description are injected into the HTML file.
import { defineConfig } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
export default defineConfig({
plugins: [
createHtmlPlugin({
inject: {
data: {
title: 'My Vite App',
description: 'This is a description for my Vite app.'
}
}
})
]
});
Minify HTML
This feature enables HTML minification during the build process. Setting `minify` to true will minify the HTML output.
import { defineConfig } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
export default defineConfig({
plugins: [
createHtmlPlugin({
minify: true
})
]
});
Custom HTML Template
This feature allows you to specify a custom HTML template file. In this example, the custom template located at `src/custom-template.html` is used.
import { defineConfig } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
export default defineConfig({
plugins: [
createHtmlPlugin({
template: 'src/custom-template.html'
})
]
});
html-webpack-plugin is a popular plugin for Webpack that simplifies the creation of HTML files to serve your bundles. It offers similar functionalities such as injecting data, minifying HTML, and using custom templates. However, it is designed specifically for Webpack, whereas vite-plugin-html is tailored for Vite.
rollup-plugin-html is a plugin for Rollup that allows you to import HTML files as strings and perform various HTML manipulations. While it provides some similar functionalities like injecting data and using custom templates, it is designed for Rollup rather than Vite.
FAQs
A plugin for vite to Minimize index.html and use lodash.template template syntax in index.html
The npm package vite-plugin-html receives a total of 250,813 weekly downloads. As such, vite-plugin-html popularity was classified as popular.
We found that vite-plugin-html demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.