我正在使用Gatsby + Wordpress组合构建投资组合网站。如果我在本地或Github页面上运行此设置,则在使用台式机/笔记本电脑时一切似乎都正常。如果我访问发布到Github页面的网站并使用移动设备查看图像,则根本不显示图像。
我找到了this solution并将其添加到我的gatsby-node.js
中,如下所示:
const _ = require(`lodash`)
const Promise = require(`bluebird`)
const path = require(`path`)
const slash = require(`slash`)
// This is the solution I found but it's not working in my case
// ----------
if (process.env.NODE_ENV === "development") {
process.env.GATSBY_WEBPACK_PUBLICPATH = "/"
}
// ----------
exports.createPages = ({ graphql, actions }) => {
...
我没有找到其他解决方案,似乎我自己也解决不了。
希望我提供了足够的信息,如果您不提出问题,我可以告诉您更多信息。预先感谢!