美文网首页
vue项目中 favicon.ico不能正确显示的问题

vue项目中 favicon.ico不能正确显示的问题

作者: 易冷zzz | 来源:发表于2018-08-07 17:18 被阅读1658次

首先将favicon.ico图片放在根目录下,通过以下两种方法使其显示正确。
方法一:修改index.html文件

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

方法二:修改webpack配置文件

1、找到build下的webpack.dev.conf.js文件

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

2、找到build下的webpack.prod.conf.js文件

 new HtmlWebpackPlugin({
      filename: config.build.index,
      template: 'index.html',
      inject: true,
      favicon: path.resolve('favicon.ico'), //新增
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
        ...
    }),

修改配置文件后重启npm run dev,大功告成。

相关文章

网友评论

      本文标题:vue项目中 favicon.ico不能正确显示的问题

      本文链接:https://www.haomeiwen.com/subject/txmavftx.html