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