vite-plugin-insert-html
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

/vite-plugin-insert-html/

    Package Sidebar

    Install

    npm i vite-plugin-insert-html

    Weekly Downloads

    17

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    20.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • notwoods