fix: static string strip regex for mulitiline static strings

this can happen when the template contains `<pre>` tags
pull/461/head
Evan You 3 years ago
parent abb1b578cd
commit bc486aae56

@ -12,7 +12,7 @@ import { OutputAsset, OutputChunk } from 'rollup'
const hashRE = /\.(\w+)\.js$/
const staticInjectMarkerRE =
/\b(const _hoisted_\d+ = \/\*(?:#|@)__PURE__\*\/\s*createStaticVNode)\("(.*)", (\d+)\)/g
const staticStripRE = /__VP_STATIC_START__.*?__VP_STATIC_END__/g
const staticStripRE = /__VP_STATIC_START__[^]*?__VP_STATIC_END__/g
const staticRestoreRE = /__VP_STATIC_(START|END)__/g
// matches client-side js blocks in MPA mode.
@ -226,6 +226,7 @@ export function createVitePressPlugin(
fileName: chunk.fileName.replace(/\.js$/, '.lean.js'),
code: chunk.code.replace(staticStripRE, ``)
}
// remove static markers from original code
chunk.code = chunk.code.replace(staticRestoreRE, '')
}

Loading…
Cancel
Save