Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Fonts are not available offline #63

Closed
paulrosen opened this issue Nov 10, 2022 · 4 comments · Fixed by #81
Closed

Fonts are not available offline #63

paulrosen opened this issue Nov 10, 2022 · 4 comments · Fixed by #81
Assignees
Labels
enhancement New feature or request

Comments

@paulrosen
Copy link

I have a PWA that mostly works offline except that the fonts only work when there is an internet connection. I'm not sure if there is something to add to the manifest and I'm not sure if there is a way to debug exactly what is happening. I tried the following in nuxt.config.ts:

export default defineNuxtConfig({
   // other stuff. etc...
  pwa: {
    manifest: {
      name: "My Name",
      lang: 'en'
    },
    workbox: {
      offlineAssets: [ "/fonts/*.ttf", "/fonts/*.woff", "/fonts/*.svg" ]
    }
},

But that doesn't help.

The fonts are in /public/fonts/*.ttf

As I said, the fonts work when the app starts up with an internet connection.

@kevinmarrec
Copy link
Owner

@paulrosen We don't have offlineAssets support here yet, but I'll work on adding it so you can pre-cache your fonts and make them available offline :)

@kevinmarrec kevinmarrec added the enhancement New feature or request label Nov 15, 2022
@kevinmarrec kevinmarrec self-assigned this Nov 15, 2022
@paulrosen
Copy link
Author

I've gotten back to this project and was excited to see this was resolved! But I can't figure out how to get it specified. It tried each of the following in nuxt.config.ts but they don't change the manifest file:

pwa: {
    workbox: {
      cacheOptions: {
        directoryIndex: '/fonts/',
        revision: '1',
      },
      offlineAssets: [
        '/fonts/*.ttf',
      ],
      runtimeCaching: [
        {
          urlPattern: "/fonts/*.ttf",
          handler: 'StaleWhileRevalidate',
          options: {
            cacheName: 'fonts'
          }
        }
      ]
    }

How do I get the manifest file to change?

@kevinmarrec
Copy link
Owner

kevinmarrec commented Feb 7, 2023

@paulrosen I implemented some preCaching option but I would need to have extra work to get runtimeCaching as well, I'll have a look to have something closer to Nuxt 2 module.

@paulrosen
Copy link
Author

Is this still in progress? I'm not positive whether the bug is in my configuration or this library but the configuration is pretty simple. My fonts are not cached.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants