Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt 3 SSG - Font not included when using @nuxt/critters #321

Open
steffenstolze opened this issue Jan 24, 2024 · 1 comment
Open

Nuxt 3 SSG - Font not included when using @nuxt/critters #321

steffenstolze opened this issue Jan 24, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@steffenstolze
Copy link

Hey there,

I realized that the Google font I'm using isn't included in the static sites generated with nuxt generate

assets/css/main.scss

/* rubik-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/rubik-v28-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

nuxt.config.ts

export default defineNuxtConfig({
  devtools: { enabled: true },
  ssr: true,
  app: {
    pageTransition: { name: 'page', mode: 'out-in' },
  },
  css: ['~/assets/css/main.scss'],
  modules: ['@nuxtjs/tailwindcss', '@nuxtjs/critters'],
  critters: {
    // https://github.com/GoogleChromeLabs/critters#critters-2
    config: {
      preload: 'swap',
      fonts: false,
    },
  },
});

Everything is working fine in dev (npm run dev) but not for the static pages. The font is just not loading.

As soon as I remove the critters module, it's there. I played around with fonts: true - didn't help.

Any idea?

Thanks!

@steffenstolze steffenstolze added the question Further information is requested label Jan 24, 2024
@maige-app maige-app bot added bug Something isn't working help wanted Extra attention is needed labels Jan 24, 2024
@zefman
Copy link

zefman commented Feb 26, 2024

I am hitting exactly the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants