JohnPremKumar / vite-plugin-favicons-inject

A Vite plugin for creating and injecting favicons during the application build!
MIT License
10 stars 3 forks source link

error favicon #9

Closed Jacknq closed 1 year ago

Jacknq commented 1 year ago

vite 4.0.4


[vite] Internal server error: URI malformed
      at decodeURI (<anonymous>)
      at viteTransformMiddleware

//vite.config

 plugins: [vue( ),
  vitePluginFaviconsInject('./public/favicon.ico'),

//html <link rel="icon" href="[<%= BASE_URL %>favicon.ico](http://localhost:8080/%3C%=%20BASE_URL%20%%3Efavicon.ico)">

JohnPremKumar commented 1 year ago

Currently .ico format files are not supported as the input to the favicon plugin. Try replacing with png, or svg files and check whether it resolves the issue.

Also you do not need to add the the below line

<link rel="icon" href="[<%= BASE_URL %>favicon.ico](http://localhost:8080/%3C%=%20BASE_URL%20%%3Efavicon.ico)">

Remove it from the html file since the required html markup will be injected automatically. If you still have doubts, you can refer the demo project in the test folder(https://github.com/JohnPremKumar/vite-plugin-favicons-inject/tree/main/test)

Jacknq commented 1 year ago

hi, I do have /favicon.ico link in html, it seems base url is generating vite with some issues, thats the reason I would use some plugin to see if that issue ll be resolved.

JohnPremKumar commented 1 year ago

You need to remove the /favicon.ico file and add your favicon in svg or png format like below:


// In vite.config.js file
plugins: [
  vue( ),
  vitePluginFaviconsInject('./src/logo.png'),
]

If you want to have a base url to be added. you can use the base config provided by Vite like below instead of the above method:


// In vite.config.js file
{
.......
plugins: [
  vue( ),
  vitePluginFaviconsInject('./src/logo.png'),
],
base: "https:://www.example.com"
.......
}
Jacknq commented 1 year ago

Thanks, I dont use base option, since I want to be universal on base, should be all relative to root and resolved on web server automatically.