Skip to content

Commit bb095db

Browse files
committed
fix(scan): avoid breaking html comment regex inside script of scanned html-like files
1 parent 1222727 commit bb095db

File tree

1 file changed

+1
-1
lines changed
  • packages/vite/src/node/optimizer

1 file changed

+1
-1
lines changed

packages/vite/src/node/optimizer/scan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function esbuildScanPlugin(
192192
async ({ path }) => {
193193
let raw = fs.readFileSync(path, 'utf-8')
194194
// Avoid matching the content of the comment
195-
raw = raw.replace(commentRE, '')
195+
raw = raw.replace(commentRE, '<!---->')
196196
const isHtml = path.endsWith('.html')
197197
const regex = isHtml ? scriptModuleRE : scriptRE
198198
regex.lastIndex = 0

0 commit comments

Comments
 (0)