diff --git a/packages/vant-cli/cjs/md-loader.cjs b/packages/vant-cli/cjs/md-loader.cjs index a158f790c..81501e928 100644 --- a/packages/vant-cli/cjs/md-loader.cjs +++ b/packages/vant-cli/cjs/md-loader.cjs @@ -49,13 +49,37 @@ const initMarkdownIt = () => { const md = initMarkdownIt(); -const markdownToVue = (raw) => { +const markdownToJs = (raw) => { let html = md.render(raw); - html = `
${html}
`; html = markdownCardWrapper(html); - // escape curly brackets - html = html.replace(//g, ''); - return ``; + + return ` + import { openBlock, createElementBlock } from 'vue'; + +const _hoisted_1 = ['innerHTML']; +const html = ${JSON.stringify(html)}; + +export default { + setup() { + return { html: '' }; + }, + render() { + return ( + openBlock(), + createElementBlock( + 'div', + { + class: 'van-doc-markdown-body', + innerHTML: html, + }, + null, + 8 /* PROPS */, + _hoisted_1, + ) + ); + }, +}; + ` }; // add target="_blank" to all links @@ -78,5 +102,5 @@ function markdownLinkOpen(md) { } module.exports = function (raw) { - return markdownToVue(raw); + return markdownToJs(raw); }; diff --git a/packages/vant-cli/src/compiler/compile-site.ts b/packages/vant-cli/src/compiler/compile-site.ts index a37ab4ed0..ff0ee01a4 100644 --- a/packages/vant-cli/src/compiler/compile-site.ts +++ b/packages/vant-cli/src/compiler/compile-site.ts @@ -79,22 +79,8 @@ export async function compileSite(isProd = false) { templateParameters: getTemplateParams(), }, tools: { - bundlerChain(chain, { CHAIN_ID }) { - const vueRule = chain.module.rules - .get(CHAIN_ID.RULE.VUE) - .use(CHAIN_ID.USE.VUE); - const vueLoader = vueRule.get('loader'); - const vueOptions = vueRule.get('options'); - - chain.module - .rule('md') - .test(/\.md$/) - .use('vue') - .loader(vueLoader) - .options(vueOptions) - .end() - .use('md') - .loader(MD_LOADER); + bundlerChain(chain) { + chain.module.rule('md').test(/\.md$/).use('md').loader(MD_LOADER); }, rspack: { plugins: [