爲VUE 腳手架中自定義title標籤頁小圖標

效果如圖所示:

小圖標效果如圖所示

1、 在項目index.html同級目錄下添加favicon.ico文件

2、 在項目index.html中引入

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

3、 配置webpack配置文件(build文件夾下面)

在下面兩個配置文件中加入:javascript

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

具體位置:html

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
 }

4、 從新運行vue項目

npm run dev
相關文章
相關標籤/搜索