1、首先将favicon.ico图片放在根目录下

2、修改webpack配置文件

1)找到build下的webpack.dev.conf.js文件

new HtmlWebpackPlugin({

filename: 'index.html',

template: 'index.html',

inject: true,

favicon: path.resolve('favicon.ico') // 新增 }),

2)找到build下的webpack.prod.conf.js文件

new HtmlWebpackPlugin({

filename: config.build.index,

template: 'index.html',

inject: true,

favicon: path.resolve('favicon.ico'), //新增

minify: { removeComments: true, collapseWhitespace: true, removeAttributeQuotes: true ... }),

修改配置文件后需重启npm run dev 
打包后根目录下就会有favicon.ico

相关文章:

  • 2021-12-31
  • 2021-10-04
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
  • 2021-10-04
  • 2021-08-19
  • 2021-09-22
猜你喜欢
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2019-01-02
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案