vue2设置浏览器icon图标

1.在index.html文件head标签内设置(图片要放在static静态资源文件夹内,防止打包之后文件图片找不到)

<link rel="shortcut icon" href="./static/images/logo.png" type="image/x-icon" />

2.在build/webpack.dev.conf.js中设置(文件内搜索 HtmlWebpackPlugin ,加入favicon属性)

new HtmlWebpackPlugin({
  filename: 'index.html',
  template: 'index.html',
  inject: true,
  favicon: path.resolve('./static/images/logo.png')
}),

3.在build/webpack.prod.conf.js中设置设置(文件内搜索 HtmlWebpackPlugin ,加入favicon属性)

    new HtmlWebpackPlugin({
      filename: config.build.index,
      template: 'index.html',
      inject: true,
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
      },
      chunksSortMode: 'dependency',
      favicon: path.resolve('./static/images/logo.png')
    }),
posted @ 2022-06-28 21:47  MELANCHOLYS  阅读(1262)  评论(0编辑  收藏  举报