Skip to content

Commit

Permalink
Update font-stylesheet-gathering-plugin.ts (#30709)
Browse files Browse the repository at this point in the history
* Update font-stylesheet-gathering-plugin.ts

For production build, getting an UnhandledPromiseRejectionWarning: Unhandled promise rejection on line 29. Added rejection handling callback to allow for builds.

This breaks deployments to Vercel.

* ensure font css minimizing errors are caught/logged

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
pklawansky and ijjk committed Feb 6, 2022
1 parent 560191a commit 0468a56
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -13,6 +13,7 @@ import {
FONT_MANIFEST,
OPTIMIZED_FONT_PROVIDERS,
} from '../../../shared/lib/constants'
import * as Log from '../../output/log'

function minifyCss(css: string): Promise<string> {
return postcss([
Expand Down Expand Up @@ -197,11 +198,18 @@ export class FontStylesheetGatheringPlugin {
const css = await fontDefinitionPromises[promiseIndex]

if (css) {
const content = await minifyCss(css)
this.manifestContent.push({
url: fontStylesheets[promiseIndex],
content,
})
try {
const content = await minifyCss(css)
this.manifestContent.push({
url: fontStylesheets[promiseIndex],
content,
})
} catch (err) {
Log.warn(
`Failed to minify the stylesheet for ${fontStylesheets[promiseIndex]}. Skipped optimizing this font.`
)
console.error(err)
}
}
}

Expand Down

0 comments on commit 0468a56

Please sign in to comment.