首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@字体-安装ParcelJS后不工作

@字体-安装ParcelJS后不工作
EN

Stack Overflow用户
提问于 2018-03-15 16:37:55
回答 1查看 1.7K关注 0票数 4

我以前设置了Gulp来使用Sass,Pug和Babel。字体装得很好。我现在开始使用包裹,除了一件事外,它正在按预期工作。字体没有加载。

以下是_fonts.sass的全部内容

代码语言:javascript
复制
@font-face
  font-family: "MyWebFont"
  src: url(../fonts/economica-regular-otf.eot)
  src: url(../fonts/economica-regular-otf.eot?#iefix) format("embedded-opentype"),
  url(../fonts/economica-regular-otf.woff2) format("woff2"),
  url(../fonts/economica-regular-otf.woff) format("woff"),
  url(../fonts/economica-regular-otf.ttf) format("ttf")

@font-face
  font-family: "MyWebFontBold"
  src: url(../fonts/economica-bold-otf.eot)
  src: url(../fonts/economica-bold-otf.eot?#iefix) format("embedded-opentype"),
  url(../fonts/economica-bold-otf.woff2) format("woff2"),
  url(../fonts/economica-bold-otf.woff) format("woff"),
  url(../fonts/economica-bold-otf.ttf) format("ttf")

body
  font-family: 'MyWebFont', 'Titillium Web', sans-serif
  text-rendering: auto
  text-rendering: geometricPrecision

文件夹结构如下:

代码语言:javascript
复制
/dist
/src
-- / pug
--- index.pug
-- / sass
--- _fonts.sass
--- _animations.sass
--- _blocks.sass
--- _elements.sass
--- styles.sass
-- / js
--- // all the scripts
-- / fonts
--- // all the fonts are here

您可以在这里找到项目文件(“新建”分支):GitHub

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-07 01:02:06

我以前修过这个。

package.json中,我将build脚本编辑为"build": "parcel build src/pug/index.pug --public-url ./ -d dist"

然后我编辑了_fonts.sass,这样@font-face就不会上目录了。例如,src: url(../fonts/economica-regular-otf.eot)变成了src: url(./fonts/economica-regular-otf.eot)

我已经有一段时间没有搞清楚这件事了,所以我不记得这背后的原因了,但它起了作用。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49304800

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档