Skip to content

Commit

Permalink
fix: static string strip regex for mulitiline static strings
Browse files Browse the repository at this point in the history
this can happen when the template contains `<pre>` tags
  • Loading branch information
yyx990803 committed Dec 5, 2021
1 parent abb1b57 commit bc486aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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, '')
}
Expand Down

0 comments on commit bc486aa

Please sign in to comment.