Vue爬坑之旅(二十二):vue中添加favicon.ico
在vue路由模式中添加favicon.ico语普通页面不同,仅仅在header中添加是没有效果的。1、首先将favicon.ico图片放在根目录下2、修改webpack配置文件(1)找到build下的webpack.dev.conf.js文件在plugins:[]下加入:new HtmlWebpackPlugin({filename: 'index....
·
在vue路由模式中添加favicon.ico语普通页面不同,仅仅在header中添加是没有效果的。
1、首先将favicon.ico图片放在根目录下
2、修改webpack配置文件
(1)找到build下的webpack.dev.conf.js文件
在plugins:[]下加入:
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon: path.resolve('favicon.ico')
}),
(2)找到build下的webpack.prod.conf.js文件
同样的在在plugins:[]下加入:
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
favicon: path.resolve('favicon.ico'),
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'
}),
修改配置文件后需重启npm run dev ,
打包后,可以看到根目录下多了一个网页icon。
更多推荐
已为社区贡献20条内容
所有评论(0)