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
hooks: {
11
"astro:config:setup": (params) => {
12
const { logger } = params
13
14
if (hasVitePlugin(params, { plugin: "vite-plugin-my-integration" })) {
15
logger.warn("Vite plugin already exists!");
16
}
17
}
18
}
19
}
20
}
21
})