From bc486aae563fd77f38da44d9ae3ea28c021f6df0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 5 Dec 2021 23:43:34 +0800 Subject: [PATCH] fix: static string strip regex for mulitiline static strings this can happen when the template contains `
` tags
---
 src/node/plugin.ts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/node/plugin.ts b/src/node/plugin.ts
index 903e456db5e9..b84e7ff6f279 100644
--- a/src/node/plugin.ts
+++ b/src/node/plugin.ts
@@ -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, '')
           }