【发布时间】:2021-10-25 14:14:19
【问题描述】:
我有一个本地 RobotoFont.tff,我在 index.scss 文件中引用它,如下所示:
@font-face {
font-family: 'Roboto';
src: url('src/assets/Roboto/Roboto-Regular.ttf') format('truetype');
}
.rb {font-family: 'Roboto';}
但我在编译时收到以下错误:
Failed to compile.
./src/assets/Roboto/Roboto-Regular.ttf 1:0
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
该项目在 React-Typescript 中,我是否需要安装链接中指定的任何特定加载器?如果是,它适用于 .ttf 文件吗?
【问题讨论】:
-
你试过这个加载器吗:npmjs.com/package/ttf-loader ?
-
试过了,添加了包,也添加到了webpack中,但是还是报同样的错误。
标签: reactjs typescript webpack fonts