Skip to content

Commit 09bef5e

Browse files
committed
feat(@142vip/vitepress): 按需引入element-plus中的组件,减少打包体积
1 parent cd3f34e commit 09bef5e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/vitepress/src/theme/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import DefaultTheme from 'vitepress/theme'
22
import type { EnhanceAppContext } from 'vitepress/dist/client'
3-
import ElementPlus from 'element-plus'
3+
import { ElBacktop, ElImage, ElTable, ElTableColumn, ElTag } from 'element-plus'
44
import type { Component } from 'vue'
55
import { h } from 'vue'
66
import type { Awaitable } from 'vitepress/types/shared'
@@ -38,7 +38,12 @@ export default function defineVipExtendsTheme(theme?: Theme) {
3838
})
3939
},
4040
enhanceApp: ({ app }: EnhanceAppContext) => {
41-
app.use(ElementPlus)
41+
// 按需引入
42+
app.component(ElBacktop)
43+
app.component(ElImage)
44+
app.component(ElTable)
45+
app.component(ElTableColumn)
46+
app.component(ElTag)
4247
},
4348
// 自定义拓展,配置覆盖
4449
...theme != null ? theme : {},

0 commit comments

Comments
 (0)