在VUE中如何显示网站ico图标

1.安装 html-webpack-plugin

npm install html-webpack-plugin -save-v
安装成功后在package.json下会生成版本号

“file-loader”: “^1.1.4”,
“friendly-errors-webpack-plugin”: “^1.6.1”,
“html-webpack-plugin”: “^2.30.1”,
修改文件
2.修改文件
webpack.dev.conf.js
# div
let path = require(‘path’) // 此处创建项目的时候就已经生成
new HtmlWebpackPlugin({
filename: ‘index.html’,
template: ‘index.html’,
inject: true,
favicon: path.resolve(‘favicon.ico’) // 增加
}),
webpack.prod.conf.js
# prod
new HtmlWebpackPlugin({
filename: config.build.index,
template: ‘index.html’,
inject: true,
favicon: path.resolve(‘favicon.ico’), //新增
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true

}),

3.重新npm run start 代码就可以看到效果了

猜你喜欢

转载自blog.csdn.net/Tong_Zai_Yuan_Fang/article/details/89489606