feat(core): allow plugins to self-disable by returning null (#10286)

This commit is contained in:
Sébastien Lorber 2024-07-10 13:13:30 +02:00 committed by GitHub
parent 8c2943421b
commit 80203b385d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 181 additions and 86 deletions

View file

@ -11,14 +11,15 @@ import type {PluginOptions, Options} from './options';
export default function pluginVercelAnalytics(
context: LoadContext,
options: PluginOptions,
): Plugin {
const isProd = process.env.NODE_ENV === 'production';
): Plugin | null {
if (process.env.NODE_ENV !== 'production') {
return null;
}
return {
name: 'docusaurus-plugin-vercel-analytics',
getClientModules() {
return isProd ? ['./analytics'] : [];
return ['./analytics'];
},
contentLoaded({actions}) {