解决方案:
首先两个配置文件;
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" />
更多精彩请关注:Vue专题