The effect is shown below:
I. In the projectindex.html
Add in the same level directoryfavicon.ico
file
Second, in the projectindex.html
The introduction of
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
Three, configuration,webpack
Configuration files (under the Build folder)
Add the following two configuration files:
favicon: path.resolve('./favicon.ico')
Specific location:
1.webpack.dev.conf.js
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
favicon: path.resolve('./favicon.ico'),
inject: true,
}),
2. webpack.prod.config.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
})
Rerun the VUE project
npm run dev