vue设置网站图标favicon.ico

位置

favicon.ico放在根目录下

方式一

index.html

<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />

方式二

webpack.dev.conf.js

new HtmlWebpackPlugin({
  filename: 'index.html',
  template: 'index.html',
  favicon: 'favicon.ico', // 新增
  inject: true
}),

webpack.prod.conf.js

new HtmlWebpackPlugin({
  filename: config.build.index,
  template: 'index.html',
  inject: true,
  minify: {
    removeComments: true,
    collapseWhitespace: true,
    removeAttributeQuotes: true
    // more options:
    // https://github.com/kangax/html-minifier#options-quick-reference
  },
  // necessary to consistently work with multiple chunks via CommonsChunkPlugin
  chunksSortMode: 'dependency',
  favicon: 'favicon.ico' // 新增
}),

猜你喜欢

转载自blog.csdn.net/qq_40055200/article/details/107178835