Skip to content

hasVitePlugin

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

For example:

my-integration/index.ts
1
import {
2
defineIntegration,
3
hasVitePlugin
4
} from "astro-integration-kit";
5
6
export default defineIntegration({
7
// ...
8
setup() {
9
return {
10
"astro:config:setup": (params) => {
11
const { logger } = params
12
13
if (hasVitePlugin(params, { plugin: "vite-plugin-my-integration" })) {
14
logger.warn("Vite plugin already exists!");
15
}
16
}
17
}
18
}
19
})