Skip to content

Commit

Permalink
fix(favicon): use publicPath with favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
craftamap committed Dec 28, 2022
1 parent a0b0278 commit 9489cb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ const htmlPlugin = (configuration = { files: [], }) => {
await fs_1.default.promises.copyFile(htmlFileConfiguration.favicon, `${outdir}/favicon.ico`);
const linkTag = document.createElement('link');
linkTag.setAttribute('rel', 'icon');
linkTag.setAttribute('href', '/favicon.ico');
let faviconPublicPath = '/favicon.ico';
if (publicPath) {
faviconPublicPath = joinWithPublicPath(publicPath, 'favicon.ico');
}
linkTag.setAttribute('href', faviconPublicPath);
document.head.appendChild(linkTag);
}
injectFiles(dom, collectedOutputFiles, outdir, publicPath, htmlFileConfiguration);
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ export const htmlPlugin = (configuration: Configuration = { files: [], }): esbui

const linkTag = document.createElement('link')
linkTag.setAttribute('rel', 'icon')
linkTag.setAttribute('href', '/favicon.ico')

let faviconPublicPath = '/favicon.ico'
if (publicPath) {
faviconPublicPath = joinWithPublicPath(publicPath, 'favicon.ico')
}
linkTag.setAttribute('href', faviconPublicPath)
document.head.appendChild(linkTag)
}

Expand Down

0 comments on commit 9489cb7

Please sign in to comment.