Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions min.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function mincss (css) {
return '#' + ((1 << 24) + ((1*r) << 16) + ((1*g) << 8) + (1*b)).toString(16).slice(1);
}

var whiteSpacePlaceHolder = '|_|';

return String(css)
.replace(/(:not\(.*?\))\s+(?!{)/g, '$1' + whiteSpacePlaceHolder) // Mark whitespace after :not() selectors for preservation
.replace(/\/\*[\s\S]*?\*\//g, ' ') // Comments
.replace(/\s+/g, ' ') // Extra spaces
.replace(/^\s+/g, '') // Extra spaces
Expand Down Expand Up @@ -112,6 +115,7 @@ function mincss (css) {
.replace(/\:\s*calc\(([^;}]+)/g, function ($0) { // Repair CSS3 calc conditions
return $0.replace(/\s+/g, "").replace(/([-+*/]+)/g, " $1 ");
})
.replace(/\|_\|/g, ' ') // Re-insert whitespaces that should be preserved
;
}

Expand Down