webpack.prod.conf.js 這個文件中: 引入代碼const path = require('path') ;下面是進行配置: new HtmlWebpackPlugin({ filename: config.build.index, template: 'index.html', favicon: path.resolve('./favicon.ico'), inject: true, }), webpack.prod.dev.js這個文件中: 引入代碼:const path = require('path') ; 下面是進行配置: new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', favicon: path.resolve('./favicon.ico'), inject: true, }),
最后很關鍵的index.html中的代碼引入:
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" rel="external nofollow" />