Skip to content

Commit 7467489

Browse files
authored
refactor: Onlyy clear source maps after all routes prerendered (#21)
1 parent 0e9c5ad commit 7467489

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/plugins/prerender-plugin.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -509,28 +509,28 @@ export function prerenderPlugin({ prerenderScript, renderTarget, additionalPrere
509509
fileName: assetName,
510510
source: htmlDoc.toString(),
511511
});
512+
}
512513

513-
// Clean up source maps if the user didn't enable them themselves
514-
if (!userEnabledSourceMaps) {
515-
for (const output of Object.keys(bundle)) {
516-
if (output.endsWith('.map')) {
517-
delete bundle[output];
518-
continue;
519-
}
514+
// Clean up source maps if the user didn't enable them themselves
515+
if (!userEnabledSourceMaps) {
516+
for (const output of Object.keys(bundle)) {
517+
if (output.endsWith('.map')) {
518+
delete bundle[output];
519+
continue;
520+
}
520521

521-
if (output.endsWith('.js')) {
522-
const codeOrSource = bundle[output].type == 'chunk' ? 'code' : 'source';
523-
if (typeof bundle[output][codeOrSource] !== 'string') continue;
522+
if (output.endsWith('.js')) {
523+
const codeOrSource = bundle[output].type == 'chunk' ? 'code' : 'source';
524+
if (typeof bundle[output][codeOrSource] !== 'string') continue;
524525

525-
const linesOfCode = bundle[output][codeOrSource].trimEnd().split('\n');
526-
if (/^\/\/#\ssourceMappingURL=.*\.map$/.test(linesOfCode.at(-1))) {
527-
linesOfCode.pop();
528-
bundle[output][codeOrSource] = linesOfCode.join('\n');
529-
}
526+
const linesOfCode = bundle[output][codeOrSource].trimEnd().split('\n');
527+
if (/^\/\/#\ssourceMappingURL=.*\.map$/.test(linesOfCode.at(-1))) {
528+
linesOfCode.pop();
529+
bundle[output][codeOrSource] = linesOfCode.join('\n');
530530
}
531531
}
532532
}
533533
}
534-
},
534+
}
535535
};
536536
}

0 commit comments

Comments
 (0)