codeAdrian / gatsby-omni-font-loader

Font loader optimized for maximum performance. Removes render-blocking font resources and loads them asynchronusly. Handle FOUT & FOUC with font loading status watcher. Supports both local-hosted fonts and web fonts.
MIT License
106 stars 7 forks source link

Errors when leaving out settigs #1

Closed stephan-swiftcom closed 3 years ago

stephan-swiftcom commented 3 years ago

Firstly thanks for the plugin, I was surprised that a plugin like this didn't already exist.

I seem to be getting errors when I leave out some of the settings in the plugin. Namely, with the following config:

      options: {
        /* Self-hosted fonts config. Add font files and font CSS files to "static" folder */`
        custom: [
          {
            /* Exact name of the font as defied in @font-face CSS rule */
            name: ['Open Sans'],
            /* Path to the font CSS file inside the "static" folder with @font-face definition */
            file: ['/fonts/fonts.css'],
          },
        ],
      },
    },

I get Unhandled Rejection (TypeError): Invalid attempt to spread non-iterable instance.

I assume this is because I'm not providing web and preconnect arrays to the plugin.

So I add some just to get the build going:

        /* Preconnect URL-s. This example is for Google Fonts */
        preconnect: ['https://fonts.gstatic.com'],
        /* Web fonts. File link should point to font CSS file. */
        web: [],

but then Helmet gives the following error:

TypeError: tag[primaryAttributeKey].toLowerCase is not a function
in
node_modules/react-helmet/lib/HelmetUtils.js:121

I assume because something else again is not initialised.

Still looking into this though, but thought I would create an issue in the meantime :)

codeAdrian commented 3 years ago

Hi @stephan-swiftcom thank you for reporting the issue. I will check it out ASAP and get back to you!

codeAdrian commented 3 years ago

Hi @stephan-swiftcom, the issue has been fixed and I've improved the code base to better handle the missing options. Bump the package to new version: "gatsby-omni-font-loader": "^1.0.4",

Let me know if everything is alright and I'll close the issue.

stephan-swiftcom commented 3 years ago

@codeAdrian Wow thanks so much! Perfectly solved all my issues, all works as expected now