Skip to content

Commit

Permalink
Remove delayed minification of CSS, seems like it's no longer necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Aug 4, 2022
1 parent b7fe525 commit b98976b
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,6 @@ async function subsetFonts(
],
};

// Keep track of the injected CSS assets that should eventually be minified
// Minifying them along the way currently doesn't work because some of the
// manipulation is sensitive to the exact text contents. We should fix that.
const subsetFontsToBeMinified = new Set();
const fontFaceDeclarationsByHtmlOrSvgAsset = new Map();
const potentiallyOrphanedAssets = new Set();

Expand Down Expand Up @@ -1021,7 +1017,7 @@ These glyphs are used on your site, but they don't exist in the font you applied
text: subsetCssText,
});

subsetFontsToBeMinified.add(cssAsset);
await cssAsset.minify();

for (const [i, fontRelation] of cssAsset.outgoingRelations.entries()) {
const fontAsset = fontRelation.to;
Expand Down Expand Up @@ -1091,7 +1087,6 @@ These glyphs are used on your site, but they don't exist in the font you applied
const existingCssAsset = assetGraph.findAssets({ url: cssAssetUrl })[0];
if (existingCssAsset) {
assetGraph.removeAsset(cssAsset);
subsetFontsToBeMinified.delete(cssAsset);
cssAsset = existingCssAsset;
} else {
cssAsset.url = cssAssetUrl;
Expand Down Expand Up @@ -1226,7 +1221,7 @@ These glyphs are used on your site, but they don't exist in the font you applied
assetGraph.removeAsset(cssAsset);
cssAsset = existingCssAsset;
} else {
subsetFontsToBeMinified.add(cssAsset);
await cssAsset.minify();
cssAsset.url = cssAssetUrl;
}

Expand Down Expand Up @@ -1311,7 +1306,7 @@ These glyphs are used on your site, but they don't exist in the font you applied
formats,
hrefType
);
subsetFontsToBeMinified.add(selfHostedGoogleFontsCssAsset);
await selfHostedGoogleFontsCssAsset.minify();
selfHostedGoogleCssByUrl.set(
googleFontStylesheetRelation.to.url,
selfHostedGoogleFontsCssAsset
Expand Down Expand Up @@ -1492,11 +1487,6 @@ These glyphs are used on your site, but they don't exist in the font you applied
}
}

// This is a bit awkward now, but if it's done sooner, it breaks the CSS source regexping:
for (const cssAsset of subsetFontsToBeMinified) {
await cssAsset.minify();
}

await assetGraph.serializeSourceMaps(undefined, {
type: 'Css',
outgoingRelations: {
Expand Down

0 comments on commit b98976b

Please sign in to comment.