perf: add vite optimize deps (#467)

This commit is contained in:
pengzhanbo 2025-02-16 15:03:31 +08:00 committed by GitHub
parent 29f9b87128
commit b13f1725f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -37,7 +37,7 @@ export function markdownPowerPlugin(
addViteOptimizeDepsInclude(
bundlerOptions,
app,
['artplayer', 'dashjs', 'hls.js', 'mpegts.js'],
['artplayer', 'dashjs', 'hls.js', 'mpegts.js/dist/mpegts.js'],
)
}
},

View File

@ -5,6 +5,7 @@ import type {
LineNumberOptions,
PreWrapperOptions,
} from './types.js'
import { addViteOptimizeDepsInclude } from '@vuepress/helper'
import { isPlainObject } from 'vuepress/shared'
import { colors } from 'vuepress/utils'
import { copyCodeButtonPlugin } from './copy-code-button/index.js'
@ -94,12 +95,22 @@ export function shikiPlugin({
extendsMarkdownOptions: (options) => {
// 注入 floating-vue 后,需要关闭 代码块 的 v-pre 配置
if ((options as any).vPre !== false) {
const vPre = isPlainObject((options as any).vPre) ? (options as any).vPre : { block: true }
const vPre = isPlainObject(options.vPre) ? options.vPre : { block: true }
if (vPre.block) {
(options as any).vPre ??= {}
options.vPre ??= {}
;(options as any).vPre.block = false
}
}
},
extendsBundlerOptions: (bundlerOptions, app) => {
if (options.twoslash) {
addViteOptimizeDepsInclude(
bundlerOptions,
app,
['floating-vue'],
)
}
},
}
}