Add Favicon with React and Webpack

前端 未结 14 2157
星月不相逢
星月不相逢 2020-12-12 19:46

I am attempting to add a favicon to a React-based website that I made using webpack. It has been a total nightmare to add a favicon and I have tried many solutions to no ava

14条回答
  •  星月不相逢
    2020-12-12 19:59

    Here is how I did.

    public/index.html

    I have added the generated favicon links.

    ...
    
    
    
    

    webpack.config.js

    new HTMLWebpackPlugin({
       template: '/path/to/index.html',
       favicon: '/path/to/favicon.ico',
    })
    

    Note

    I use historyApiFallback in dev mode, but I didn't need to have any extra setup to get the favicon work nor on the server side.

提交回复
热议问题