vue 添加favicon.ico


第一种: 修改index.html头部加载文件

<link rel="shortcuticon" type="image/x-icon" href="favicon.ico" /> 
缺点: 打包后需要将favicon.ico复制到根目录
 
 

第二种: 

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
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM