Gatsby构建缺少图像的路径前缀



运行npm run deploy(由"deploy": "gatsby build && gh-pages -d public -b master"组成(后,它成功部署,但映像不在那里。我意识到它们在<noscript>标签后面,显然缺少路径前缀。以下是回购:https://github.com/daletom/gatsby-universal它部署在这里:http://thedales.me/gatsby-universal/

我确实在我的gastby-config.jspathPrefix: "/gatsby-universal",中添加了路径前缀,我尝试运行gatsby-build,然后是gatsby-uild——路径前缀,然后是npm运行build(以及包括路径前缀在内的许多其他组合(

这是当前显示的图像代码:

<noscript><picture><source srcset="/static/d83d4906eafa1a2c85b17c2f9569a2b7/b1f33/1.jpg 1x,
/static/d83d4906eafa1a2c85b17c2f9569a2b7/2a252/1.jpg 1.5x,
/static/d83d4906eafa1a2c85b17c2f9569a2b7/fe3b3/1.jpg 2x" /><img loading="lazy" width="500" height="500" srcset="/static/d83d4906eafa1a2c85b17c2f9569a2b7/b1f33/1.jpg 1x,
/static/d83d4906eafa1a2c85b17c2f9569a2b7/2a252/1.jpg 1.5x,
/static/d83d4906eafa1a2c85b17c2f9569a2b7/fe3b3/1.jpg 2x" src="/static/d83d4906eafa1a2c85b17c2f9569a2b7/b1f33/1.jpg" alt="React Context" style="position:absolute;top:0;left:0;opacity:1;width:100%;height:100%;object-fit:cover;object-position:center"/></picture></noscript>

如果它是/gatsby universal/static/image.jpg,那么它实际上会起作用,这就是为什么我认为路径前缀搞砸了

对我来说,问题似乎是路径被缓存了。再次运行gatsby cleangatsby build --prefix-paths修复了它。

终于明白了,显然我应该做的是前缀路径

最新更新