First put the favicon.ico image in the root directory, and make it display correctly by the following two methods.
Method 1: Modify the index.html file
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
Method 2: Modify the webpack configuration file
1. Find the webpack.dev.conf.js file under build
new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', inject: true, favicon: path.resolve('favicon.ico') // increase }),
2. Find the webpack.prod.conf.js file under build
new HtmlWebpackPlugin({ filename: config.build.index, template: 'index.html', inject: true, favicon: path.resolve('favicon.ico'), //new minify: { removeComments: true, collapseWhitespace: true, removeAttributeQuotes: true ... }),After modifying the configuration file, you need to restart npm run dev.