Skip to content

Commit

Permalink
perf: add vite optimize deps (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo authored Feb 16, 2025
1 parent 29f9b87 commit b13f172
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/plugin-md-power/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
)
}
},
Expand Down
15 changes: 13 additions & 2 deletions plugins/plugin-shikiji/src/node/shikiPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'],
)
}
},
}
}

0 comments on commit b13f172

Please sign in to comment.