Skip to content

Commit

Permalink
fix(meta): fix issues regarding favicon.ico fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 7, 2020
1 parent e4a052a commit 7a1e773
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/meta/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ function generateMeta (pwa) {
}

// Icons
if (options.favicon && options.icons && options.icons.length > 0) {
if (options.icons && options.icons.length > 0) {
const iconSmall = options.icons[0]
const iconBig = options.icons[options.icons.length - 1]

// Shortcut icon
head.link.push({ rel: 'shortcut icon', href: iconSmall.src })
head.link.push({ rel: 'apple-touch-icon', href: iconBig.src, sizes: iconBig.sizes })
if (options.favicon) {
head.link.push({ rel: 'shortcut icon', href: iconSmall.src })
head.link.push({ rel: 'apple-touch-icon', href: iconBig.src, sizes: iconBig.sizes })
}

// Launch Screen Image (IOS)
if (options.mobileAppIOS && pwa._iosSplash) {
Expand All @@ -134,14 +136,13 @@ function generateMeta (pwa) {
})
}
}
}

// Favicon.ico as fallback
const favicon = join(nuxt.options.srcDir, nuxt.options.dir.static, 'favicon.ico')
if (options.favicon && existsSync(favicon)) {
// eslint-disable-next-line no-console
console.warn('You are using a low quality icon, use icon png. See https://pwa.nuxtjs.org/icon')
head.link.push({ rel: 'shortcut icon', href: nuxt.options.router.base + 'favicon.ico' })
} else {
// favicon.ico as fallback
// TODO: Drop support as it is harmful: https://mathiasbynens.be/notes/rel-shortcut-icon
const favicon = join(nuxt.options.srcDir, nuxt.options.dir.static, 'favicon.ico')
if (existsSync(favicon)) {
head.link.push({ rel: 'shortcut icon', href: nuxt.options.router.base + 'favicon.ico' })
}
}

// Title
Expand Down

0 comments on commit 7a1e773

Please sign in to comment.