小编Tec*_*emn的帖子

部署到 Vercel 时,Google 字体未加载到 Next.js 中

运行应用程序时,http://localhost:3000一切正常且看起来很棒。但将我的 Next.js 应用程序部署到 Vercel 后,字体没有显示,日志中也没有显示任何内容。

我遵循了 Next.js 文档中的建议,这就是我的_document.tsx样子 -

import { Global } from '@mantine/core'
import { createGetInitialProps } from '@mantine/next'
import Document, { Head, Html, Main, NextScript } from 'next/document'

const getInitialProps = createGetInitialProps()

export default class _Document extends Document {
    static getInitialProps = getInitialProps

    render() {
        return (
            <Html>
                <Head>
                    <link rel="preconnect" href="https://fonts.googleapis.com" />
                    <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />
                    <link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Lora:ital@0;1&family=Roboto+Condensed:wght@300;700&display=swap" rel="stylesheet" />
                    <Global
                        styles={(theme) => ({
                            'body': {
                                backgroundColor: theme.colors.gray[3],
                                color: theme.colors.gray[8],
                                fontFamily: …
Run Code Online (Sandbox Code Playgroud)

next.js google-fonts vercel mantine

6
推荐指数
2
解决办法
1万
查看次数

Webpack - 外部 JS/JSON 文件作为依赖项

朋友们,我试图将外部文件保留在 Webpack 捆绑包之外,但仍保留为依赖项 - 在本例中为设置文件。我尝试了以下几种变体 -

externals: {
  'Settings': JSON.stringify(require('./settings.json'))
},
Run Code Online (Sandbox Code Playgroud)

...但 Webpack 继续将其包含在捆绑包中。我在文档中找到的唯一示例是常见的预设(例如 jQuery),没有提到本地文件而是外部文件。帮助?谢谢!

ecmascript-6 webpack

5
推荐指数
1
解决办法
1886
查看次数

标签 统计

ecmascript-6 ×1

google-fonts ×1

mantine ×1

next.js ×1

vercel ×1

webpack ×1