
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
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 193,639 weekly downloads. As such, vite-plugin-html popularity was classified as popular.
We found that vite-plugin-html demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.