【发布时间】:2021-11-17 02:30:41
【问题描述】:
我想为项目添加本地字体。
我正在使用来自styled-components 的next.js 和globalStyles。
这是我到目前为止所做的
import regularFont from "../public/fonts/IRANYekanRegular.ttf";
const GlobalStyle = createGlobalStyle<{ lang?: Languages_type | string }>`
@font-face {
font-family: "ir";
src: local("ir"), url(${regularFont}) format("truetype");
}
body,
html {
margin: 0;
font-family:"ir ";
}
`;
但是上面的代码会抛出错误
./public/fonts/IRANYekanRegular.ttf 模块解析失败:意外 字符 '' (1:0) 你可能需要一个合适的加载器来处理这个 文件类型,目前没有配置加载器来处理这个文件。 见https://webpack.js.org/concepts#loaders(源代码省略 这个二进制文件)
我错过了什么?
【问题讨论】:
标签: reactjs next.js styled-components