在做项目的过程中,发现按照之前的方法设置.ico无效
然后发现需要修改build中的配置才可以
1、将你像设置的ico文件放在static目录下,是为了防止打包之后,文件只存在index.html和static而找不到ico文件的情况
2、index.html中设置
<link rel="shortcut icon" href="./static/favicon.ico" type="image/x-icon" />
3、build/webpack.dev.conf.js中设置
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
**favicon: path.resolve('./static/favicon.ico')**
}),
build/webpack.prod.conf.js中设置
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
**favicon: path.resolve('./static/favicon.ico')*
.......