对于Spring boot通常我们会采用maven方式统一将前后台代码打包在一起进行部署,往往页面的favicon是默认的绿叶图标,下面讲一下如何自定义favicon.
在Vue的项目代码中build文件夹,修改文件webpack.prod.conf.js
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
......
添加关于favicon打包配置,例如:
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
favicon: path.resolve('./favicon.ico'),
......
通常把自定义的图标文件和index.html放在一起,这样maven打包后的文件自动包括了favicon.ico文件。
注意,在部署以后需要清理浏览器缓存,这样就可以看到自定义图标出现了。
Good Luck.
Cheers!