为VUE 脚手架中自定义title标签页小图标

7次阅读

共计 700 个字符,预计需要花费 2 分钟才能阅读完成。

效果如图所示:

一、在项目 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
}

正文完
 0