|
|
@@ -235,22 +235,21 @@ this.fontsMinifier = this.fontsMinifier || (() => {
|
|
|
const filterSource = fontSource => fontInfo.filter(source => source == fontSource || source.src.startsWith(LOCAL_SOURCE));
|
|
|
stats.fonts.processed += fontInfo.length;
|
|
|
stats.fonts.discarded += fontInfo.length;
|
|
|
- let woffFontFound = findSource("woff2-variations") || findSource("woff2") || findSource("woff");
|
|
|
- let filteredFontInfo = fontInfo;
|
|
|
+ const woffFontFound = findSource("woff2-variations") || findSource("woff2") || findSource("woff");
|
|
|
if (woffFontFound) {
|
|
|
- filteredFontInfo = filterSource(woffFontFound);
|
|
|
+ fontInfo = filterSource(woffFontFound);
|
|
|
} else {
|
|
|
- let ttfFontFound = findSource("truetype-variations") || findSource("truetype");
|
|
|
+ const ttfFontFound = findSource("truetype-variations") || findSource("truetype");
|
|
|
if (ttfFontFound) {
|
|
|
- filteredFontInfo = filterSource(ttfFontFound);
|
|
|
+ fontInfo = filterSource(ttfFontFound);
|
|
|
} else {
|
|
|
- let otfFontFound = findSource("opentype") || findSource("embedded-opentype");
|
|
|
+ const otfFontFound = findSource("opentype") || findSource("embedded-opentype");
|
|
|
if (otfFontFound) {
|
|
|
- filteredFontInfo = filterSource(otfFontFound);
|
|
|
+ fontInfo = filterSource(otfFontFound);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- stats.fonts.discarded -= filteredFontInfo.length;
|
|
|
+ stats.fonts.discarded -= fontInfo.length;
|
|
|
const removedNodes = [];
|
|
|
for (let node = cssRule.block.children.head; node; node = node.next) {
|
|
|
if (node.data.property == "src") {
|
|
|
@@ -261,8 +260,8 @@ this.fontsMinifier = this.fontsMinifier || (() => {
|
|
|
removedNodes.forEach(node => cssRule.block.children.remove(node));
|
|
|
const srcDeclaration = cssRule.block.children.filter(node => node.property == "src").tail;
|
|
|
if (srcDeclaration) {
|
|
|
- filteredFontInfo.reverse();
|
|
|
- srcDeclaration.data.value = cssTree.parse(filteredFontInfo.map(fontSource => fontSource.src).join(","), { context: "value" });
|
|
|
+ fontInfo.reverse();
|
|
|
+ srcDeclaration.data.value = cssTree.parse(fontInfo.map(fontSource => fontSource.src).join(","), { context: "value" });
|
|
|
}
|
|
|
}
|
|
|
|