Skip to content

Commit

Permalink
chore: remove the console warning
Browse files Browse the repository at this point in the history
  • Loading branch information
LiHowe committed May 13, 2022
1 parent cb8cb72 commit de9ab07
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/client/enhance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ import Mermaid from './Mermaid'
export default defineClientAppEnhance(({ app }) => {
if (!__VUEPRESS_SSR__) {
customElements.define('h-mermaid', Mermaid)
app.config.compilerOptions.isCustomElement = tag => tag.startsWith('h-')
}
})
24 changes: 24 additions & 0 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,29 @@ export default (opt: Record<string, string | number | boolean> = {}) => ({
extendsMarkdown: (md: any) => {
md.__mermaidConfig = opt
md.use(MermaidPlugin)
},
extendsBundlerOptions: (bundlerOptions, app) => {
// 修改 @vuepress/bundler-vite 的配置项
if (app.options.bundler.name === '@vuepress/bundler-vite') {
bundlerOptions.vuePluginOptions ??= {}
bundlerOptions.vuePluginOptions.template ??= {}
bundlerOptions.vuePluginOptions.template.compilerOptions ??= {}
const isCustomElement = bundlerOptions.vuePluginOptions.template.compilerOptions.isCustomElement
bundlerOptions.vuePluginOptions.template.compilerOptions.isCustomElement = (tag) => {
if (isCustomElement?.(tag)) return true
if (tag === 'h-mermaid') return true
}
}

// 修改 @vuepress/bundler-webpack 的配置项
if (app.options.bundler.name === '@vuepress/bundler-webpack') {
bundlerOptions.vue ??= {}
bundlerOptions.vue.compilerOptions ??= {}
const isCustomElement = bundlerOptions.vue.compilerOptions.isCustomElement
bundlerOptions.vue.compilerOptions.isCustomElement = (tag) => {
if (isCustomElement?.(tag)) return true
if (tag === 'h-mermaid') return true
}
}
}
})

0 comments on commit de9ab07

Please sign in to comment.