ico不显示的问题
在用vue脚手架搭建的项目中发现页面标题的ico图标总也显示不出来,后来发现不仅仅是需要在<head>
里面写上<link rel="shortcut icon" href="./favicon.ico">
就可以的,还需要配置一下webpack的配置。
webpack.dev.conf.js
//在webpack.dev.conf.js里面的pligins配置增加favicon
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon: './favicon.ico'
})
webpack.prod.conf.js
//在webpack.prod.conf.js里面也要增加favicon
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
favicon: './favicon.ico',
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
},
chunksSortMode: 'dependency'
})
在index.html中加入favicon
<link rel="shortcut icon" href="./favicon.ico">