我正在使用 gatsby-plugin-sass 来包含我的 sass 文件。我有一个web-animations.sass
导入的文件_typography.sass
. My _typography.sass
有一个像这样的字体声明:
@font-face
font-family: 'BrandonPrinted'
src: url(../../global/fonts/brandonprinted-one-webfont.eot)
src: url(../../global/fonts/brandonprinted-one-webfont.eot?#iefix) format('embedded-opentype'), url(../../global/fonts/brandonprinted-one-webfont.woff) format('woff'), url(/src/page-assets/global/fonts/brandonprinted-one-webfont.ttf) format('truetype')
当我跑步时gatsby develop
我收到此错误:
ERROR Failed to compile with 2 errors 19:51:15
These relative modules were not found:
* ../../global/fonts/brandonprinted-one-webfont.eot in ./~/css-loader!./~/sass-loader?{"plugins":[]}!./src/page-assets/work-ive-done/subpages/web-animations/styles/web-animations.sass
* ../../global/fonts/brandonprinted-one-webfont.woff in ./~/css-loader!./~/sass-loader?{"plugins":[]}!./src/page-assets/work-ive-done/subpages/web-animations/styles/web-animations.sass
字体 url 路径似乎被解释为相对于web-animations.sass
而不是相对于_typography.sass
因为如果我搬家web-animations.sass
上升两级,那么这个错误就会消失。
有没有办法拥有_typography.sass
寻找相对于其自身位置的字体文件?
似乎这个问题已经解决了,但万一将来有人遇到这个问题并需要替代解决方案我在这里回答了类似的问题 https://stackoverflow.com/a/56053550/379841并包含一个带有部署站点的存储库,演示了通过 Sass 使用静态文件的不同方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)