【发布时间】:2019-01-14 07:10:21
【问题描述】:
我目前有一个库,它可以导出一些 SCSS,其中包含位于子文件夹中的字体路径。
- nodemodules/library/fonts/font.scss
- 字体文件,例如在 nodemodules/library/fonts/bold/xyz.eot
SCSS 在我的 node_modules 文件夹中的 font.scss 中如下所示
@font-face {
font-family: "Daimler";
font-weight: "normal";
font-style: "italic";
src: url($font-path + '.eot') format("embedded-opentype"),
url($font-path + '.ttf') format("ttf");
}
该文件将被导入到 src 文件夹中 main.scss 文件中的 angular 项目中。该文件夹将从 Angular 构建复制到具有以下设置的资产
{
"glob": "**/*",
"input": "nodemodules/library/fonts/",
"output": "/assets/fonts"
}
我的问题是 $font-path 应该是什么样子,或者我需要解决什么问题。我已经尝试过但没有用的东西(总是无法解析路径):
./assets/fonts/bold/xyz.eot (can't resolve because relativ path is wrong from main.scss, but should be correct since that will be the destination the files will be copied to from the angular build)
/src/assets/fonts/bold/xyz.eot (building the project works, but path is wrong on runtime)
问题是 CSS-Loader 将始终检查 url,在构建应用程序时,它总是尝试解析 src/assets 的路径,其中显然没有文件,因为它们只会被复制到目标文件夹(来自 cli-config)。
有什么解决办法吗?
【问题讨论】:
标签: angular webpack sass angular-cli css-loader