The favicon.ico in vue displays the tutorial correctly

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325857927&siteId=291194637