Skip to content

Commit

Permalink
fix(pwa): null check icon paths (#5087)
Browse files Browse the repository at this point in the history
  • Loading branch information
janispritzkau committed Mar 19, 2020
1 parent 3633cf5 commit c8e6450
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js
Expand Up @@ -81,22 +81,26 @@ module.exports = class HtmlPwaPlugin {

const assetsVersionStr = assetsVersion ? `?v=${assetsVersion}` : ''

data.head.push(
// Favicons
makeTag('link', {
// Favicons
if (iconPaths.favicon32 != null) {
data.head.push(makeTag('link', {
rel: 'icon',
type: 'image/png',
sizes: '32x32',
href: getTagHref(publicPath, iconPaths.favicon32, assetsVersionStr)
}),
makeTag('link', {
}))
}
if (iconPaths.favicon16 != null) {
data.head.push(makeTag('link', {
rel: 'icon',
type: 'image/png',
sizes: '16x16',
href: getTagHref(publicPath, iconPaths.favicon16, assetsVersionStr)
}),
}))
}

// Add to home screen for Android and modern mobile browsers
// Add to home screen for Android and modern mobile browsers
data.head.push(
makeTag('link', manifestCrossorigin
? {
rel: 'manifest',
Expand All @@ -111,9 +115,11 @@ module.exports = class HtmlPwaPlugin {
makeTag('meta', {
name: 'theme-color',
content: themeColor
}),
})
)

// Add to home screen for Safari on iOS
// Add to home screen for Safari on iOS
data.head.push(
makeTag('meta', {
name: 'apple-mobile-web-app-capable',
content: appleMobileWebAppCapable
Expand All @@ -125,22 +131,30 @@ module.exports = class HtmlPwaPlugin {
makeTag('meta', {
name: 'apple-mobile-web-app-title',
content: name
}),
makeTag('link', {
})
)
if (iconPaths.appleTouchIcon != null) {
data.head.push(makeTag('link', {
rel: 'apple-touch-icon',
href: getTagHref(publicPath, iconPaths.appleTouchIcon, assetsVersionStr)
}),
makeTag('link', {
}))
}
if (iconPaths.maskIcon != null) {
data.head.push(makeTag('link', {
rel: 'mask-icon',
href: getTagHref(publicPath, iconPaths.maskIcon, assetsVersionStr),
color: themeColor
}),
}))
}

// Add to home screen for Windows
makeTag('meta', {
// Add to home screen for Windows
if (iconPaths.msTileImage != null) {
data.head.push(makeTag('meta', {
name: 'msapplication-TileImage',
content: getTagHref(publicPath, iconPaths.msTileImage, assetsVersionStr)
}),
}))
}
data.head.push(
makeTag('meta', {
name: 'msapplication-TileColor',
content: msTileColor
Expand Down

0 comments on commit c8e6450

Please sign in to comment.