favicon is not displayed using react-static-plugin-favicons

173 Views Asked by At

I would like to display a favicon using the lib react-static-plugin-favicons.

I added it to my static.config.js :

export default {
  entry: path.join(__dirname, 'src', 'index.tsx'),
  getRoutes: async () => {
    return [
      {
        path: '/',
        template: 'src/containers/individuals.tsx'
      }
    ]
  },

  plugins: [
    require.resolve("react-static-plugin-sass"),
    ['react-static-plugin-typescript', { typeCheck: true }],
    [
      require.resolve('react-static-plugin-source-filesystem'),
      {
        location: path.resolve('./src/page'),
      },
    ],
    require.resolve('react-static-plugin-reach-router'),
    require.resolve('react-static-plugin-sitemap'),
    [
      'react-static-plugin-favicons',
      { inputFile: path.resolve('./src/assets', 'favicon-32px.png') },
    ]
  ],
  basePath: basepath,
  Document: ({
    Html,
    Head,
    Body,
    children,
    state: { siteData, renderMeta },
  }) => (
      <Html lang="en-US">
        <Head>
          <meta charSet="UTF-8" />
          <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        </Head>
        <Body>{children}</Body>
      </Html>
    ),
}

And this is my file structure : enter image description here

Can you spot what did I do wrong because it doesn't work ? Thanks

1

There are 1 best solutions below

0
On

I tried this plugin as well and could not get it to work - however adding the file as favicon.ico to the public folder worked for me as suggested at https://github.com/react-static/react-static/issues/1483.