vite-plugin-insert-html
v1.0.2
Published
Super simple Vite plugin to insert HTML into the head or body of your HTML entrypoints
Downloads
587
Maintainers
Readme
vite-plugin-insert-html
Super simple Vite plugin to insert HTML into the head or body of your HTML entrypoints.
This plugin takes advantage of Vite's existing HTML serializer, and has no other dependencies. Use it to inject social metadata, analytics scripts, or any HTML that you need to insert in every page of your Vite app.
Installation
npm install --save-dev vite-plugin-insert-html
Usage
// vite.config.js
import { insertHtml, h } from 'vite-plugin-insert-html';
export default {
plugins: [
insertHtml({
head: [
h('meta', {
name: 'viewport',
content: 'width=device-width, initial-scale=1.0',
}),
],
body: [h('script', { src: 'analytics.js' })],
}),
],
};