为VUE 脚手架中自定义title标签页小图标

发布时间:2019-05-26 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了为VUE 脚手架中自定义title标签页小图标脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
效果如图所示:

小图标效果如图所示

一、 在项目index.htML同级目录下添加favicon.ico文件

二、 在项目index.html中引入

<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico"  />

三、 配置webpack配置文件(build文件夹下面)

在下面两个配置文件中加入:

favicon: path.resolve('./favicon.ico')

具体位置:

1.webpack.PRod.conf.js

new HtmlWebpackPlugin({ 
    filename: config.build.index, 
    template: 'index.html', 
    favicon: path.resolve('./favicon.ico'), 
    inject: true, 
}), 

2. webpack.prod.dev.js

new HtmlWebpackPlugin({
      filename: process.env.NODE_ENV === 'testing'
        ? 'index.html'
        : config.build.index,
      template: 'index.html',
      favicon: path.resolve('./favicon.ico'),
      inject: true,
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
        // more options:
        // https://github.COM/kangax/html-minifier#options-quick-reference
 }

四、 重新运行vue项目

    npm run dev

脚本宝典总结

以上是脚本宝典为你收集整理的为VUE 脚手架中自定义title标签页小图标全部内容,希望文章能够帮你解决为VUE 脚手架中自定义title标签页小图标所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。