mirror of
https://github.com/Floriansylvain/compact-portfolio.git
synced 2026-08-19 11:43:19 +02:00
fix: minifyHTML to handle whitepsaces better
This commit is contained in:
@@ -161,7 +161,14 @@ class AssetProcessor {
|
||||
minifyHTML(src) {
|
||||
return src
|
||||
.replace(/<!--(?!\[if)[\s\S]*?-->/g, "")
|
||||
.replace(/>\s+</g, "><")
|
||||
.replace(/>\s+</g, (match, offset, string) => {
|
||||
const before = string.substring(0, offset + 1);
|
||||
const after = string.substring(offset + match.length - 1);
|
||||
if (/span[^>]*>\s*$/.test(before) && /^\s*<span/.test(after)) {
|
||||
return "> <";
|
||||
}
|
||||
return "><";
|
||||
})
|
||||
.replace(/>\s+([^<]+?)\s+</g, ">$1<")
|
||||
.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, (m, css) =>
|
||||
m.replace(css, this.minifyCSS(css))
|
||||
|
||||
Reference in New Issue
Block a user