首页 > 解决方案 > 所以我尝试在我的 gatsby-config.js 文件中添加 gatsby-plugin-favicon

问题描述

首先,我在 gatsby-config.js 文件中添加 gatsby-plugin-favicon,代码如下:

module.exports = {
  siteMetadata: {
    title: 'Chatbiz Blog',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-catch-links',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    'gatsby-transformer-remark',
    {
      resolve: 'gatsby-plugin-favicon',
      options: {
        logo: "./src/images/icon.png",
        icons: {
          android: true,
          appleIcon: true,
          appleStartup: true,
          coast: false,
          favicons: true,
          firefox: true,
          twitter: false,
          yandex: false,
          windows: false
        }
      }
    }
  ],
}

完成添加 gatsby-plugin-favicon 后,出现这样的错误

WebpackError: ENOENT: no such file or directory, open 'C:\Users\setia\myrep  ository\GatsbyJS\gatsby_crash_course\public\.iconstats.json'

所以问题是我该如何解决这个问题?

标签: webpackgatsby

解决方案


转到gatsby-config.js文件并删除下面提到的依赖项

icon: `src/images/gatsby-icon.png`,

推荐阅读