为VUE 脚手架中自定义title标签页小图标
效果如图所示:

一、 在项目index.html同级目录下添加favicon.ico文件

二、 在项目index.html中引入
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
三、 配置webpack配置文件(build文件夹下面)
在下面两个配置文件中加入:
favicon: path.resolve('./favicon.ico')具体位置:
1.webpack.prod.conf.js
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
favicon: path.resolve('./favicon.ico'),
inject: true,
}),2. webpack.prod.dev.js
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
favicon: path.resolve('./favicon.ico'),
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
}四、 重新运行vue项目
npm run dev
相关推荐
道北吴彦祖 2014-11-11
johncena 2014-11-11
huangkanII 2015-06-08
icecoffeemzp 2017-10-25
85266431 2015-08-24
mahara 2014-12-20
fish 2016-06-23
xxuncle 2019-06-30
ajhongshaorou 2017-10-25
张大晴 2019-06-28
loopstang 2015-12-10
sorryericsson 2013-08-24
段雷 2011-10-06
道北吴彦祖 2014-12-02
scnjl 2010-01-26
springflower 2018-12-10
jackwelton 2018-06-19