Skip to content

hasVitePlugin

hasVitePlugin checks whether a Vite plugin has already been added to the Astro config. For example:

my-integration/index.ts
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!");
}
}
}
}
})