【问题标题】:Is there a way to add a favicon in react-static?有没有办法在 react-static 中添加图标?
【发布时间】:2020-05-09 06:39:45
【问题描述】:

我看到了

enter link description here

然后我像这样添加 favicon

import path from 'path';
import React from 'react';

export default {
  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" />
        <link rel="shortcut icon" href="favicon.ico" />
        <link rel="icon" href="favicon.ico" />
      </Head>
      <Body>{children}</Body>
    </Html>
  ),
  plugins: [
    ...
  ],
}

但不工作

也许图像在 A 中无法正常工作。我尝试将图像放入 &lt;body&gt; 中,但没有正确输出。

【问题讨论】:

    标签: html reactjs react-static


    【解决方案1】:

    通过构建它来解决。

    我使用react-static-plugin-favicons插件在服务器上构建它。

     [
          'react-static-plugin-favicons',
          { 
    
            outputDir: path.join(__dirname, 'dist'),
            inputFile: path.resolve(__dirname, 'favicon.png') },
        ],
    
    

    使用netlify

    【讨论】:

    猜你喜欢
    • 2023-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 2020-01-14
    • 2020-03-20
    相关资源
    最近更新 更多