Skip to content

Commit b13f172

Browse files
authored
perf: add vite optimize deps (#467)
1 parent 29f9b87 commit b13f172

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

plugins/plugin-md-power/src/node/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function markdownPowerPlugin(
3737
addViteOptimizeDepsInclude(
3838
bundlerOptions,
3939
app,
40-
['artplayer', 'dashjs', 'hls.js', 'mpegts.js'],
40+
['artplayer', 'dashjs', 'hls.js', 'mpegts.js/dist/mpegts.js'],
4141
)
4242
}
4343
},

plugins/plugin-shikiji/src/node/shikiPlugin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
LineNumberOptions,
66
PreWrapperOptions,
77
} from './types.js'
8+
import { addViteOptimizeDepsInclude } from '@vuepress/helper'
89
import { isPlainObject } from 'vuepress/shared'
910
import { colors } from 'vuepress/utils'
1011
import { copyCodeButtonPlugin } from './copy-code-button/index.js'
@@ -94,12 +95,22 @@ export function shikiPlugin({
9495
extendsMarkdownOptions: (options) => {
9596
// 注入 floating-vue 后,需要关闭 代码块 的 v-pre 配置
9697
if ((options as any).vPre !== false) {
97-
const vPre = isPlainObject((options as any).vPre) ? (options as any).vPre : { block: true }
98+
const vPre = isPlainObject(options.vPre) ? options.vPre : { block: true }
9899
if (vPre.block) {
99-
(options as any).vPre ??= {}
100+
options.vPre ??= {}
100101
;(options as any).vPre.block = false
101102
}
102103
}
103104
},
105+
106+
extendsBundlerOptions: (bundlerOptions, app) => {
107+
if (options.twoslash) {
108+
addViteOptimizeDepsInclude(
109+
bundlerOptions,
110+
app,
111+
['floating-vue'],
112+
)
113+
}
114+
},
104115
}
105116
}

0 commit comments

Comments
 (0)