【发布时间】:2020-06-03 14:02:24
【问题描述】:
我们使用gatsby-plugin-manifest 来生成清单文件并导入我们的网站图标。一切都在我们的本地开发服务器上正常运行,就像加载了图标一样。
但是,当我们构建网站的静态 HTML 并在我们的服务器上运行此文件时,所有图标都会出现 404 错误:/icons/icon-48x48.png?v=0a830f59a4abe247647ea123ff4fc96e'. It looks like our service worker can not resolve the URL of/icons`。当我们将图标目录移动到 gatsby 的静态目录时,一切正常。
我是否遗漏了 gatsby-config.js 文件中的某些内容?这是我们用于gatsby-plugin-manifest 的部分。
resolve: `gatsby-plugin-manifest`,
options: {
name: "Keytoe",
short_name: "Keytoe",
start_url: "/",
background_color: "#23e197",
theme_color: "#23e197",
// Enables "Add to Homescreen" prompt and disables browser UI (including back button)
// see https://developers.google.com/web/fundamentals/web-app-manifest/#display
display: "standalone",
icon: "src/assets/logo/favicon.png", // This path is relative to the root of the site.
// An optional attribute which provides support for CORS check.
// If you do not provide a crossOrigin option, it will skip CORS for manifest.
// Any invalid keyword or empty string defaults to `anonymous`
crossOrigin: `use-credentials`,
},
},
【问题讨论】: