Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Next.js 如何在下一个js中加载otf和ttf字体_Next.js_Truetype - Fatal编程技术网

Next.js 如何在下一个js中加载otf和ttf字体

Next.js 如何在下一个js中加载otf和ttf字体,next.js,truetype,Next.js,Truetype,尝试在nextjs应用程序中加载ttf字体。添加了next字体并配置了next.config.js文件。 但这是错误的 ModuleParseError: Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. 这是我的下一个

尝试在nextjs应用程序中加载ttf字体。添加了next字体并配置了next.config.js文件。 但这是错误的

ModuleParseError: Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. 
这是我的下一个.config.js

const webpack = require("webpack");
const withCss = require("@zeit/next-css");
const withSass = require("@zeit/next-sass");
const withFonts = require("next-fonts");
require("dotenv").config({
  path: `.env.${process.env.NODE_ENV || "development"}`
});
module.exports = withFonts(
  withSass(
    withCss({
      assetPrefix: process.env.BASE_PATH || "",
      basePath: process.env.BASE_PATH || "",
      publicRuntimeConfig: {
        basePath: process.env.BASE_PATH || ""
      },
      webpack: (config, { isServer }) => {     
        config.node = {
          fs: "empty"
        };
        if (isServer) {
          const antStyles = /antd\/.*?\/style\/css.*?/;
          const origExternals = [...config.externals];
          config.externals = [
            (context, request, callback) => {
              if (request.match(antStyles)) return callback();
              if (typeof origExternals[0] === "function") {
                origExternals[0](context, request, callback);
              } else {
                callback();
              }
            },
            ...(typeof origExternals[0] === "function" ? [] : origExternals)
          ];

          config.module.rules.unshift({
            test: antStyles,
            use: "null-loader"
          });
        }     
        const env = Object.keys(process.env).reduce((acc, curr) => {
          acc[`process.env.${curr}`] = JSON.stringify(process.env[curr]);
          return acc;
        }, {});        
        config.plugins.push(new webpack.DefinePlugin(env));
        return config;
      }
    })
  )
);
我在public/fonts/ceraPRo-Black.ttf中放置了字体,在public/scss/stye.scss中放置了css文件 scss文件

@font-face {
  font-family: CeraPro;
  src: url("../fonts/Cera/CeraPro-Medium.ttf");
  font-weight: 300;
  font-style: normal;
}
body {
  font-family: "CeraPro";
  font-weight: 400; 
}
如何解决此问题。

这可能会回答您的问题?