1.0.2 • Published 3 months ago

vite-plugin-insert-html v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

vite-plugin-insert-html

npm.io

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' })],
    }),
  ],
};