我想要什么,我想知道什么我想在Next.js應用程序中自托管字體(即 Noto),該應用程序已經使用了@zeit/next-less插件。我需要使用 npm-package next-fonts來自托管字體嗎?如果是這樣,我是否需要使用 npm-package next-compose-plugins來使 next-fonts 和 next-less 一起工作?我是否需要將字體(如 WOFF(2))下載到/public我的應用程序存儲庫中的目錄中?還是直接使用像fontsource-noto-sans這樣的 npm-package 來提供這些字體?我試過的我嘗試使用 next-compose-plugins 一起使用 next-fonts 和 next-less。我創建了這個/next.config.js:const WithPlugins = require('next-compose-plugins');const WithFonts = require('next-fonts');const WithLess = require('@zeit/next-less');module.exports = WithPlugins( [ [ WithFonts, {} ], [ WithLess, {} ] ], {});在我的單個全局少文件中,我放了這個:@font-face { font-family: 'Noto Serif'; font-style: normal; font-weight: 400; font-display: swap; src: local('Noto Serif'), local('NotoSerif'), url('/public/fonts/noto-serif.woff2') format('woff2');}body { font-family: 'Noto Serif', // and for debugging: monospace;}我下載了 Noto 的字體文件并將它們放在…/public/fontsNext.js-application 文件夾中的文件夾中。Noto 字體未加載,等寬字體繼續使用。任何想法為什么?以及如何使用 Next.js + next-less 輕松自托管字體的任何想法?
Next.js 中帶有 next-less 的自托管字體
蝴蝶不菲
2022-10-13 16:10:44