Git Product home page Git Product logo

fonts's Introduction

Nuxt banner

Nuxt

Version Downloads License Website Discord

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including:

  • Server-side rendering, Static Site Generation, Hybrid Rendering and Edge-Side Rendering
  • Automatic routing with code-splitting and pre-fetching
  • Data fetching and state management
  • SEO Optimization and Meta tags definition
  • Auto imports of components, composables and utils
  • TypeScript with zero configuration
  • Go fullstack with our server/ directory
  • Extensible with 200+ modules
  • Deployment to a variety of hosting platforms
  • ...and much more πŸš€

Table of Contents


Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies:

npx nuxi@latest init <my-project>

Tip

Discover also nuxt.new: Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds.

Simple, intuitive and powerful, Nuxt lets you write Vue components in a way that makes sense. Every repetitive task is automated, so you can focus on writing your full-stack Vue application with confidence.

Example of an app.vue:

<script setup lang="ts">
useSeoMeta({
  title: 'Meet Nuxt',
  description: 'The Intuitive Vue Framework.'
})
</script>

<template>
  <div id="app">
    <AppHeader />
    <NuxtPage />
    <AppFooter />
  </div>
</template>

<style scoped>
#app {
  background-color: #020420;
  color: #00DC82;
}
</style>

We highly recommend you take a look at the Nuxt documentation to level up. It’s a great resource for learning more about the framework. It covers everything from getting started to advanced topics.

Discover our list of modules to supercharge your Nuxt project, created by the Nuxt team and community.

We invite you to contribute and help improve Nuxt πŸ’š

Here are a few ways you can get involved:

  • Reporting Bugs: If you come across any bugs or issues, please check out the reporting bugs guide to learn how to submit a bug report.
  • Suggestions: Have ideas to enhance Nuxt? We'd love to hear them! Check out the contribution guide to share your suggestions.
  • Questions: If you have questions or need assistance, the getting help guide provides resources to help you out.

Follow the docs to Set Up Your Local Development Environment to contribute to the framework and documentation.

You can find the code for Nuxt 2 on the 2.x branch and the documentation at v2.nuxt.com.

If you expect to be using Nuxt 2 beyond the EOL (End of Life) date (June 30, 2024), and still need a maintained version that can satisfy security and browser compatibility requirements, make sure to check out HeroDevs’ NES (Never-Ending Support) Nuxt 2.

DiscordΒ Β TwitterΒ Β GitHub

MIT

fonts's People

Contributors

arashsheyda avatar atinux avatar danielroe avatar dargmuesli avatar qwerzl avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fonts's Issues

Fonts discovered in bundle generation don't generate preload tags

@danielroe

It seems the preload-tag is not generated for fonts, that are defined in tailwind.config.ts.

I define my font in tailwind-config like this:

	theme: {
		fontFamily: {
			body: ['"Felipa"', ...defaultTheme.fontFamily.sans],
		},
	},

And then set this css inside assets/css/tailwind.css:

  html {
    @apply font-body;
  }

Basically, nuxt/fonts is correctly picking up and downloading this font with everything seemingly working correctly, but it does not create the preload-tag.

Here is a stackblitz:
https://stackblitz.com/edit/nuxt-starter-xrzkqs?file=app.vue

If you add this to app.vue, the preload-tag gets added correctly:

<style scoped>
div {
  font-family: Felipa, serif;
}
</style>

Originally posted by @codeflorist in #24 (comment)

Allow downloading priority by extensions

Is it possible to specify the priority of downloading files by their extension (woff 2, woff, tff)? Now, if a folder contains both ttf and woff2 at the same time, then the module loads tff. Or do I only need to store fonts in woff2 format?

image
image

Support use of CSS variables for font-family names

Hi :)
I define my font families using CSS variables / tokens, and it seems the module won't parse it.

Given:

:root {
  --font-family-base: Lexend, sans-serif;
  --font-family-heading: Quicksand, sans-serif;
}

and usage:

html,
body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: 1.6;
}

fonts are not loaded. However, if i add lets say Lexend to the font-family before the variable, everything works.

I have no idea of the "doability" of this, just wanted to point that out as it doesnt seem someone did already.

I'll stay with fontaine only for now πŸ˜„ cheers

"Tuples must be sorted" error with google fonts provider and multiple font weights

I'm encounting an error when using google fonts provider and multiple font weights. Nuxt reports a 400 bad request error. Looks like Google enforces a sorted tuple for requests.

Request link: https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;1,100;0,200;1,200;0,300;1,300;0,400;1,400;0,500;1,500;0,600;1,600;0,700;1,700

Error from Google:

400: Invalid selector
Tuples must be sorted
IBM Plex Mono:ital,wght@0,100;1,100;0,200;1,200;0,300;1,300;0,400;1,400;0,500;1,500;0,600;1,600;0,700;1,700

My config:

fonts: {
  families: [
    { name: 'IBM Plex Mono', provider: 'google' },
  ],
  defaults: {
    weights: [100, 200, 300, 400, 500, 600, 700, 800, 900],
    styles: ['normal', 'italic'],
    subsets: [
      'latin-ext',
      'latin',
    ],
  },
  assets: {
    prefix: '/_fonts',
  },
},

Future of @nuxtjs/google-fonts

Hi @danielroe

  • Should we deprecate the @nuxtjs/google-fonts module in favor of this module?
  • It is a widely used module, do I continue to support it?
  • Should I add a note indicating the use of nuxt/fonts?

Allow specifying text for font families

With google fonts you can specify which characters you need and by that reducing the size.
This is already possible with the module google-fonts but I'm not seeing an option in this module.
Be aware there's a issue/PR currently on the google fonts repo regarding the text option per font family
nuxt-modules/google-fonts#106

Failure to match font weights for `fontshare` provider when the `weights` defined in the config is composed of strings.

When the weights are defined string arrays in the config, the fontshare provider would fail to match the correct weights because of the type mismatch.

My config:

export default defineNuxtConfig({
  modules: ['@nuxt/fonts', '@nuxtjs/tailwindcss', '@unocss/nuxt'],
  unocss: {
    disableNuxtInlineStyle: false,
  },
  fonts: {
    providers: {
      custom: '~/providers/custom'
    },
    families: [
      { name: 'Abel', provider: 'bunny' },
      { name: 'Satoshi', provider: 'fontshare' },
      { name: 'Kode Mono', provider: 'none' },
      { name: 'MyCustom', src: '/custom-font.woff2' },
      { name: 'CustomGlobal', global: true, src: '/font-global.woff2' },
      { name: 'Oswald', fallbacks: ['Times New Roman'] },
    ],
    defaults: {
      weights: ['400', '700'],
      fallbacks: {
        monospace: ['Tahoma']
      }
    }
  },
})

variable fonts support

This might be more of a question type issue due to missing knowledge on my end.

I tried setting up the module to replace our current google font dependency:
@import url("https://fonts.googleapis.com/css2?family=Encode+Sans:wght@100;200;300;400;500;600;700;800;900&display=swap")

However when comparing the font output I noticed that google downloads a single 27kb woff2 file while nuxt/fonts creates 5 distinct woff files, ~40kb each -> 200kb.
After a bit of searching I learned about variable fonts and Encode Sans seems to be one of them.

So the question would be whether there is some sort of special config needed to make variable font's work properly? That is assuming the cause for the discrepancy is variable fonts of course.

Thanks!

This is the config used:

fonts: {
	families: [{ name: "Encode Sans", provider: "google" }],
	defaults: {
		weights: [100, 200, 300, 400, 500, 600, 700, 800, 900],
		styles: ["normal"],
		subsets: ["cyrillic-ext", "cyrillic", "greek-ext", "greek", "vietnamese", "latin-ext", "latin"],
	},

	assets: {
		prefix: "/_fonts",
	},
},

nuxt/fonts does not honour the nuxt baseUrl setting

When I set the nuxt baseURL (I set it at run time via the NUXT_APP_BASE_URL env var), nuxt/fonts can no longer access its cached fonts.

It appears that it always sets the font url to start with /_fonts no matter what, rather than /_fonts. While I didn't try I assume cdnURL will also not work with nuxt fonts.

While I need to set the NUXT_APP_BASE_URL at runtime, as a test I tried rebuilding the app with the fonts.assets.prefix setting hard coded to /prefix/_fonts and running it with NUXT_APP_BASE_URL=/prefix/, but fonts.assets.prefix changed the path of the fonts within the public directory, not the URL through which the fonts are accessed.

Is there any way to use nuxt fonts with a baseUrl set to anything but '/'?

devtools: If the module contains "@nuxt/devtools", an error occurs in the Fonts panel.

It's strange, but if the nuxt.config file contains @nuxt/devtools inside modules, the font panel doesn't work.

https://github.com/dungsil/issues/blob/0f11e1fcd386b289835d8d19c6b9199f66aa748c/nuxt-fonts-106/nuxt.config.ts#L6

image

ERROR [nuxt-devtools] RPC error on executing "nuxt-devtools-fonts:getFonts":
[birpc] function "nuxt-devtools-fonts:getFonts" not found

Reproduction link: https://github.com/dungsil/issues/tree/main/nuxt-fonts-106

Support Tailwind CSS v4

Tailwind v4 moves configuration into CSS instead of tailwind.config.js. https://tailwindcss.com/blog/tailwindcss-v4-alpha

For example in v4 to specify a custom font, you'd just do this and then you can use .font-display within your HTML. (example from their blog post)

/* main.css */
@import "tailwindcss";

@theme {
  --font-family-display: "Satoshi", "sans-serif";
}

Workaround

Currently the workaround to use Tailwind CSS v4 with Nuxt Fonts is simply to specify using font-family in the CSS so it's loaded in.

@import "tailwindcss";

@theme {
  --font-family-marker: "Permanent Marker", cursive;
}

.nuxt-fonts-permanent-marker {
  font-family: "Permanent Marker", cursive;
}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/changelogensets.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/cache v4
  • codecov/codecov-action v4
.github/workflows/release.yml
  • actions/checkout v4.1.6@a5ac7e51b41094c92402da3b24376905380afc29
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
.github/workflows/reproduction-close.yml
  • actions/stale v9.0.0@28ca1036281a5e5922ead5184a1bbf96e5fc984e
.github/workflows/reproduction.yml
  • actions/checkout v4.1.6@a5ac7e51b41094c92402da3b24376905380afc29
  • Hebilicious/reproduire v0.0.9@4b686ae9cbb72dad60f001d278b6e3b2ce40a9ac
npm
client/package.json
  • @iconify-json/carbon ^1.1.34
  • @nuxt/devtools-kit ^1.3.2
  • @nuxt/kit ^3.11.2
docs/package.json
  • @iconify-json/heroicons ^1.1.21
  • @iconify-json/ph ^1.1.13
  • @iconify-json/simple-icons ^1.1.103
  • @nuxt/content ^2.12.1
  • @nuxt/fonts ^0.7.0
  • @nuxt/image ^1.7.0
  • @nuxt/ui-pro ^1.2.0
  • @nuxtjs/mdc ^0.7.1
  • @vueuse/core ^10.10.0
  • @vueuse/nuxt ^10.10.0
  • nuxt ^3.11.2
  • nuxt-og-image ^2.2.4
  • @nuxthq/studio ^1.1.1
  • vue-tsc ^2.0.19
package.json
  • @nuxt/devtools-kit ^1.3.2
  • @nuxt/kit ^3.11.2
  • chalk ^5.3.0
  • css-tree ^2.3.1
  • defu ^6.1.4
  • esbuild ^0.21.4
  • fontaine ^0.5.0
  • globby ^14.0.1
  • h3 ^1.11.1
  • jiti ^1.21.0
  • magic-regexp ^0.8.0
  • magic-string ^0.30.10
  • node-fetch-native ^1.6.4
  • ohash ^1.1.3
  • pathe ^1.1.2
  • sirv ^2.0.4
  • ufo ^1.5.3
  • unplugin ^1.10.1
  • unstorage ^1.10.2
  • @iconify-json/carbon ^1.1.34
  • @nuxt/eslint-config ^0.3.13
  • @nuxt/module-builder ^0.7.0
  • @nuxt/schema ^3.11.2
  • @nuxt/test-utils ^3.13.1
  • @types/css-tree ^2.3.7
  • @types/splitpanes ^2.2.6
  • @vitest/coverage-v8 ^1.6.0
  • birpc ^0.2.17
  • changelogen ^0.5.5
  • consola ^3.2.3
  • eslint ^9.3.0
  • execa ^9.1.0
  • nitropack ^2.9.6
  • nuxt ^3.11.2
  • ofetch ^1.3.4
  • playwright-core ^1.44.1
  • semver ^7.6.2
  • shiki ^1.6.1
  • typescript ^5.4.5
  • unbuild ^2.0.0
  • vite ^5.2.12
  • vitest ^1.6.0
  • vue-bundle-renderer ^2.1.0
  • vue-tsc ^2.0.19
  • pnpm 9.1.4
playground/package.json
  • @unocss/nuxt ^0.60.3
  • tailwindcss ^3.4.3
  • unocss ^0.60.3
  • sass ^1.77.3

  • Check this box to trigger a request for Renovate to run again on this repository

Two local fonts familly, Only one legible

Here is my config code

families: [
      {
        name: 'Display',
        src: '/fonts/Display/',
        weights: ['200', '300', '400', '500', '700', '900'],
        display: 'swap',
      },
      {
        name: 'Narr',
        src: '/fonts/Narr/',
        weights: ['100', '300', '400', '500', '700', '900'],
        display: 'swap',
      },
    ],

and this structure of my font file

image

The Narr font is already readable, and the display font not readable like this.

image

This font won't work on production: DM Serif Display

Thought this issue was related to my project, but I was able to reproduce it, sounds weird but this font won't work on a production build - https://fonts.google.com/specimen/DM+Serif+Display

I am using the font by mentioning it in my tailwind config

import type { Config } from "tailwindcss";

export default <Partial<Config>>{
  theme: {
    fontFamily: {
      sans: [
        "DM Sans",
        "Avenir Next",
        "Roboto",
        "-apple-system",
        "BlinkMacSystemFont",
        '"Segoe UI"',
        "Ubuntu",
        '"Helvetica Neue"',
        "Arial",
        '"Noto Sans"',
        "sans-serif",
        '"Apple Color Emoji"',
        '"Segoe UI Emoji"',
        '"Segoe UI Symbol"',
        '"Noto Color Emoji"',
      ],
      mono: [
        "Cascadia Code",
        "ui-monospace",
        "SFMono-Regular",
        "Menlo",
        "Monaco",
        "Consolas",
        "Liberation Mono",
        "Courier New",
        "monospace",
      ],
      display: ["DM Serif Display", "Inter", "sans-serif"],
    },
  },
  plugins: [require("@tailwindcss/typography")],
};

The first font DM Sans is loads correctly, but the display font wont, throws a 404 in production.

Here's a reproduction - https://github.com/fayazara/nuxt-font-repro

Dev environment screenshot
Screenshot 15-04 at 19

Production screenshot
Screenshot 15-04 at 19

improve font providers

each provider supports some very interesting things, including axes for variable fonts, that we are not always taking advantage of.

would be nice to:

  • support passing options to a provider (e.g. google can accept a text option to refine the subset)
  • look at and improve google, fontshare, bunny providers

woff2 should be first in local fonts

When ttf, woff, woff2 files are used, in the resulting css woff2 files should be generated in the first place. Now they are generated for the last. example
@font-face{font-family:Mont;src:url(../fonts/Mont/Mont-100.ttf) format(truetype),url(../fonts/Mont/Mont-100.woff) format(woff),url(../fonts/Mont/Mont-100.woff2) format(woff2);font-display:swap;font-weight:100;font-style:normal}

Variable Fonts?

Does this module support variable fonts? It works with the google-fonts module, but I would be interested in switching to this module at some point if variable font support is added.

Local fonts with multiple weights but same name

I can't see it mentioned in the README how this use case would be handled, so I thought I'd open an issue to get it clarified, then I can submit a PR for the docs.

For font faces that have the same name but multiple font-weights, how would we handle the configuration for this?

E.G.

@font-face {
    font-display: swap;
    font-style: normal;
    font-weight: 400;
    font-family: 'Tenon';
    src:
        local('Tenon Regular'),
        local('Tenon-Regular'),
        local('TenonRegular'),
        url('/fonts/tenon_regular.woff2') format('woff2'),
        url('/fonts/tenon_regular.woff') format('woff');
}

/* Tenon */
/* Font weight: Medium */
@font-face {
    font-display: swap;
    font-style: normal;
    font-weight: 500;
    font-family: 'Tenon';
    src:
        local('Tenon Medium'),
        local('Tenon-Medium'),
        local('TenonMedium'),
        url('/fonts/tenon_medium.woff2') format('woff2'),
        url('/fonts/tenon_medium.woff') format('woff');
}

/* Tenon */
/* Font weight: Bold */
@font-face {
    font-display: swap;
    font-style: normal;
    font-weight: 700;
    font-family: 'Tenon';
    src:
        local('Tenon Bold'),
        local('Tenon-Bold'),
        local('TenonBold'),
        url('/fonts/tenon_bold.woff2') format('woff2'),
        url('/fonts/tenon_bold.woff') format('woff');
}

This has 3 font files for Tenon, but all under the font-family: 'Tenon'. Changing the font-weight lets the browser choose the right font file automatically.

Just wondering how we'd set this up, as well as get the local fallbacks.

Out of the box I just get the 400 weight font files, and no local fallback

Adobe font provider does not support dynamic subset

@nuxt/font is fetching CSS files from Adobe Typekit. However, for fonts with East Asian languages, it is unable to fetch the CSS extensions.

const css = await fontCSSAPI<string>(`${fonts.kits[kit]!.id}.css`)

Below is the difference in the Adobe fonts screen:

Inter Variable ( css file include )
image

Pretendard ( javascript file include )
image

East Asian characters (especially CJK) seem to have a large size, so Adobe can't import the entire font by default or all characters.
image

If you look at the actual API being called, you'll see that East Asian languages don't come with css files.

Can you add support for these areas?
If not, you can update the documentation to avoid confusing Asian users.

In the logs, it looks like this, making it difficult to determine the cause.
image

Reference:

  1. Adobe fonts docs: https://helpx.adobe.com/kr/fonts/using/dynamic-subsetting.html
  2. Test font (Pretendard): https://fonts.adobe.com/fonts/pretendard

ERROR: Could not download font metadata

I think @Nuxt/fonts unable to download font meta data behind proxy server. All other tools (npm, pnpm) work fine.

Error:

[@nuxt/fonts]  ERROR  Could not download google font metadata. @nuxt/fonts will not be able to inject @font-face rules for google.


[@nuxt/fonts]  ERROR  Could not download bunny font metadata. @nuxt/fonts will not be able to inject @font-face rules for bunny.


[@nuxt/fonts]  ERROR  Could not download fontshare font metadata. @nuxt/fonts will not be able to inject @font-face rules for fontshare.

System info:

Nuxt project info:

------------------------------
- Operating System: Windows_NT
- Node Version:     v21.6.2
- Nuxt Version:     3.11.1
- CLI Version:      3.11.0
- Nitro Version:    2.9.4
- Package Manager:  [email protected]
- Builder:          -
- User Config:      build, content, css, devtools, experimental, fonts, image, imports, lodash, modules, nitro, notivue, pinia, postcss, router, routeRules, runtimeConfig, security, seo, ssr, studio, telemetry, typescript, vite, vuetify, vueuse, vue
- Runtime Modules:  @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/test-utils/[email protected], @nuxthq/[email protected], @nuxtjs/[email protected], @pinia/[email protected], @sidebase/[email protected], @vue-email/[email protected], @vueuse/[email protected], notivue/nuxt, [email protected], [email protected], [email protected], [email protected]
- Build Modules:    -
------------------------------

devtools integration/panel

would be nice to display information on what fonts that have been detected, and which provider they come from

Nuxt DevTools error

Hey πŸ‘‹

Recently I have set up new Nuxt project with fonts module and based on v 0.2 I am receiving regular errors in console:

 ERROR  [unhandledRejection] [birpc] timeout on calling "nuxt-devtools-fonts:exposeFonts"  11:08:21  

  at Timeout._onTimeout (/C:/Users/zanfr/Work/Code/SmartCity/web-next/node_modules/birpc/dist/index.mjs:42:23)
  at listOnTimeout (node:internal/timers:573:17)
  at process.processTimers (node:internal/timers:514:7)

The errors seems to be displayed on regular interval on it own after dev server is running for some time. Can't really say.
If needed I will try to give reproduction, altho, its fresh Nuxt project.

Add support for font-stretch

Hi, this is the module I was waiting the most for nuxt especially the preload links injection and to handle fonts easilly.
I am facing one issue, I am working on a current project using the famous Helvetica Neue Pro fonts. The problem is I am using the Extented version of the font and so I use the css property font-stretch: expanded;.
Is it possible to add the support of font-stretch and have the same replica of what I have currenlty: I don't want to change my font-weight/font-family/font-stretch since the project is soon ready to be deployed.

My current font face:

@font-face {
 font-family: 'Helvetica Neue';
 src: url('/fonts/HelveticaNeue-Roman.woff2') format('woff2');
 font-weight: 400;
 font-style: normal;
 font-display: swap;
}

@font-face {
  font-family: 'Helvetica Neue';
  src: url('/fonts/HelveticaNeue-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
 }

// Expanded/Extended

@font-face {
  font-family: 'Helvetica Neue';
  src: url('/fonts/HelveticaNeue-ExtendedOblique.woff2') format('woff2');
  font-weight: 400;
  font-stretch: expanded;
  font-style: italic;
  font-display: swap;
 }

@font-face {
  font-family: 'Helvetica Neue';
  src: url('/fonts/HelveticaNeue-HeavyExtendedOblique.woff2') format('woff2');
  font-weight: 900;
  font-stretch: expanded;
  font-style: italic;
  font-display: swap;
 }

initial documentation

Tasks

Styles are not minified at build time

Hey,

First, that package is incredible. Nothing to do and works perfectly out of the box.

But I see in my build code that the font rules are not minified. Is that wanted? (see Tailwind at the end that is correctly minified)

image

Support for automatic `link rel="preload"` elements for fonts

SEO- and performance-wise it makes sense to add a <link rel="preload" head-tag for the fonts used by the site.

Since font-file-names and -locations can change (e.g. because of version/hashes), it would be great, if nuxt/fonts does that automatically. Ideally it could be enabled by family, like e.g.:

{ name: 'My Font Family', provider: 'google', preload: true },

Cannot start nuxt: Failed to get devtools context.

Environment

Version

v0.7.0

Reproduction

https://stackblitz.com/~/github.com/larrasu/frontend-mentor

cd solutions/invoice-app
pnpm dev

Description

I've been experiencing this error in various projects. I'm not sure why I can't reproduce the error on Stackblitz. It's the same repo and branch. The error is still showing up on my end as of now. The only way to get rid of this error is by removing @nuxt/fonts from the nuxt.config.ts. So I figured there is a conflict between@nuxt/fonts and @nuxt/devtools?

Logs

 ERROR  Cannot start nuxt:  Failed to get devtools context.                         12:09:04 AM

  at extendServerRpc (node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxt/devtools-kit/dist/index.mjs:96:11)
  at node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxt/fonts/dist/module.mjs:1137:11
  at node_modules/.pnpm/[email protected]/node_modules/hookable/dist/index.mjs:48:66
  at Object.run (node_modules/.pnpm/[email protected]/node_modules/hookable/dist/index.mjs:41:43)
  at node_modules/.pnpm/[email protected]/node_modules/hookable/dist/index.mjs:48:56
  at async enableModule (/Users/larrasu/.nvm/versions/node/v16.15.1/lib/node_modules/@nuxt/devtools/dist/chunks/module-main.mjs:8466:3)
  at async normalizedModule (/Users/larrasu/.nvm/versions/node/v16.15.1/lib/node_modules/@nuxt/devtools/node_modules/@nuxt/kit/dist/index.mjs:169:17)
  at async installModule (node_modules/.pnpm/@[email protected]/node_modules/@nuxt/kit/dist/index.mjs:2415:95)
  at async initNuxt (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_fl_br3acc34oknouixgtiqiyrhd6y/node_modules/nuxt/dist/index.mjs:4233:7)
  at async NuxtDevServer._load (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/dev2.mjs:6879:5)

docs(readme): suggestions

I'd like to suggest specifying

  • if subdirectories of the public directories are scanned for font files as well or if only the root directories are scanned
  • if integration with TailwindCSS works right away (many people use it I think, so many might wonder if additional configuration is necessary)

in the README

Support for custom Google Fonts baseUrl

It would be nice to offer to customize baseUrl for Google Fonts provider in the config. My use case is that there's a high latency to Google Fonts in China, so many of us use mirrors.

feat: fontsource provider

I've explored other font providers, looks like fontsource is also quite promising.

Currently most of its fonts are from Google Fonts, along with some icons and some other fonts. It's also the service that Cloudflare Fonts is fetching from.

@danielroe Would you like to include this font provider? If so, I'd like to work on it.

Docs: https://fontsource.org/docs

Font is not loading

Hello guys!

I followed the documentation and tried a couple of settings/scenarios, but cannot make it work in some of my Nuxt projects - the font is not loaded.
There's used tailwindcss, so the font family is specified there;

export default {
  ...
  theme: {
    extend: {
      fontFamily: {
        sans: ['Inter', ...defaultTheme.fontFamily.sans],
      },
      ...
    },
  },
}

but the font is not loaded and just used system default.

I also tried to specify it within my main.scss file (that is specified in nuxt.config.ts, of course):

...
body {
  font-family: Inter, sans-serif;
}

But that doesn't help.
As well as trying some fine-grained settings in the Nuxt config file:

export default defineNuxtConfig({
  ...
  fonts: {
    families: [{ name: 'Inter', provider: 'google' }],
    defaults: {
      weights: [400, 500, 600, 700],
      styles: ['normal', 'italic'],
      subsets: ['latin-ext', 'latin'],
    },
  },
  ...
})

as well as this:

export default defineNuxtConfig({
  ...
  fonts: {
    families: [
      {
        name: 'Inter',
        provider: 'google',
        weights: [400, 500, 600, 700],
        styles: ['normal', 'italic'],
        subsets: ['latin-ext', 'latin'],
      },
    ],
  },
  ...
})

I see there are a few other issues that mention some problems with the variable font (and I'm trying to use Inter which is variable), so I'm not sure if it's related to some variable font support issue (if any) or there is something else.
I would be grateful if you could point this out to me.

Nuxt baseURL ignored when resolving cached font path

Hello,

Nuxt baseURL is ignored in production.

Given app.baseURL: '/myapp/':

Actual behavior: fonts are dumped in .output/public/_fonts/ but resolved as https://domain.com/_fonts/

Expected behavior: fonts should indeed be dumped in .output/public/_fonts/ but font urls should point to https://domain.com/myapp/_fonts/

It works fine in development when path assets.prefix is set to /myapp/_fonts. However if this path is set to production, fonts are dumped in .output/public/myapp/_fonts/ and resolved to https://domain.com/myapp/_fonts/ which doesn't exist as it's now https://domain.com/myapp/myapp/_fonts/.

Nuxt fonts: 0.5.1
Nuxt: 3.11.1

Minimal reproduction: https://stackblitz.com/edit/github-4bvlvu?file=nuxt.config.ts (then manually navigate to /myapp in the preview)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.