Skip to content

Commit 742f581

Browse files
committed
feat(core): show warning when duplicate plugins are detected
1 parent 5db5351 commit 742f581

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/@vuepress/core/src/app/appUse.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { chalk, debug } from '@vuepress/utils'
1+
import { chalk, debug, warn } from '@vuepress/utils'
22
import type { App, Plugin, PluginOptions } from '../types'
33
import { normalizePlugin } from './normalizePlugin'
44

@@ -21,6 +21,13 @@ export const appUse = <T extends PluginOptions>(
2121
)
2222
if (duplicateIndex !== -1) {
2323
app.pluginApi.plugins.splice(duplicateIndex, 1)
24+
25+
// show warning when duplicate plugins are detected
26+
warn(
27+
`plugin ${chalk.magenta(
28+
plugin.name
29+
)} has been used multiple times, only the last one will take effect`
30+
)
2431
}
2532
}
2633

0 commit comments

Comments
 (0)