hasVitePlugin checks whether a Vite plugin has already been added to the Astro config. For example:
hasVitePlugin
import { defineIntegration } from "astro-integration-kit";import { hasVitePluginPlugin } from "astro-integration-kit/plugins"; export default defineIntegration({ name: "my-integration", plugins: [hasVitePluginPlugin], setup() { return { "astro:config:setup": ({ hasVitePlugin, logger }) => { if (hasVitePlugin("vite-plugin-my-integration")) { logger.warn("Vite plugin already exists!"); } } } }})
import type { AstroIntegration } from "astro";import { hasVitePlugin } from "astro-integration-kit/utilities"; export default function myIntegration(): AstroIntegration { return { name: "my-integration", hooks: { "astro:config:setup": ({ config, logger }) => { if (hasVitePlugin({ plugin: "vite-plugin-my-integration", config, })) { logger.warn("Vite plugin already exists!") } }, } }}