Skip to content

Commit 8946569

Browse files
committed
Add font optimizations
1 parent 974409c commit 8946569

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

gatsby-config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,29 @@ module.exports = {
7878
// mergeSecurityHeaders: false,
7979
// },
8080
// },
81+
{
82+
/* Include plugin */
83+
resolve: 'gatsby-omni-font-loader',
84+
85+
/* Plugin options */
86+
options: {
87+
/* Font loading mode */
88+
mode: 'async',
89+
90+
/* Enable font loading listener to handle FOUT */
91+
enableListener: true,
92+
93+
/* Self-hosted fonts config. Add font files and font CSS files to "static" folder */
94+
custom: [
95+
{
96+
/* Exact name of the font as defied in @font-face CSS rule */
97+
name: ['Apercu-Mono-Pro'],
98+
/* Path to the font CSS file inside the "static" folder with @font-face definition */
99+
file: '/assets/fonts/fonts.css',
100+
},
101+
],
102+
},
103+
},
81104
{
82105
resolve: `gatsby-plugin-manifest`,
83106
options: {

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"babel-plugin-styled-components": "^2.0.2",
99
"dotenv": "^14.1.0",
1010
"gatsby": "^4.5.2",
11+
"gatsby-omni-font-loader": "^1.3.3",
1112
"gatsby-plugin-anchor-links": "^1.2.1",
1213
"gatsby-plugin-csp": "^1.1.3",
1314
"gatsby-plugin-google-analytics": "^4.5.0",

0 commit comments

Comments
 (0)