Skip to content

Commit

Permalink
feat(@142vip/vitepress): 按需引入element-plus中的组件,减少打包体积
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdapl committed Oct 22, 2024
1 parent cd3f34e commit 09bef5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vitepress/src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DefaultTheme from 'vitepress/theme'
import type { EnhanceAppContext } from 'vitepress/dist/client'
import ElementPlus from 'element-plus'
import { ElBacktop, ElImage, ElTable, ElTableColumn, ElTag } from 'element-plus'
import type { Component } from 'vue'
import { h } from 'vue'
import type { Awaitable } from 'vitepress/types/shared'
Expand Down Expand Up @@ -38,7 +38,12 @@ export default function defineVipExtendsTheme(theme?: Theme) {
})
},
enhanceApp: ({ app }: EnhanceAppContext) => {
app.use(ElementPlus)
// 按需引入
app.component(ElBacktop)
app.component(ElImage)
app.component(ElTable)
app.component(ElTableColumn)
app.component(ElTag)
},
// 自定义拓展,配置覆盖
...theme != null ? theme : {},
Expand Down

0 comments on commit 09bef5e

Please sign in to comment.