Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change favicon Vuejs?

How to change favicon on Vuejs CLI ?

<link rel="shortcut icon" type="image/png" href="/src/assets/img/logo.png"/>
like image 497
DenisMasot Avatar asked Nov 08 '18 20:11

DenisMasot


2 Answers

Vue CLI (3.0.5) generates projects with the <root>/public directory containing the favicon.ico and index.html (which references the favicon.ico).

It seems you have your icon in <root>/src/assets. I recommend moving it to <root>/public, replacing favicon.ico with jinane-logo-JC.png, and updating index.html accordingly:

<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico"> --> <!-- REPLACE THIS -->
<link rel="icon" href="<%= BASE_URL %>jinane-logo-JC.png">
like image 159
tony19 Avatar answered Oct 27 '22 00:10

tony19


(function() {
    var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
    link.type = 'image/x-icon';
    link.rel = 'shortcut icon';
    link.href = 'http://www.stackoverflow.com/favicon.ico';
    document.getElementsByTagName('head')[0].appendChild(link);
})();
like image 25
Pankaj Rupapara Avatar answered Oct 26 '22 22:10

Pankaj Rupapara