Skip to content

Commit

Permalink
fix: handle potential string quote mismatch in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 5, 2021
1 parent bc486aa commit dfa7c05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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 @@ -224,7 +224,7 @@ export function createVitePressPlugin(
bundle[name + '-lean'] = {
...chunk,
fileName: chunk.fileName.replace(/\.js$/, '.lean.js'),
code: chunk.code.replace(staticStripRE, ``)
code: chunk.code.replace(staticStripRE, `""`)
}

// remove static markers from original code
Expand Down

0 comments on commit dfa7c05

Please sign in to comment.