Skip to content

Commit c8e6450

Browse files
fix(pwa): null check icon paths (vuejs#5087)
1 parent 3633cf5 commit c8e6450

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js

+31-17
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,26 @@ module.exports = class HtmlPwaPlugin {
8181

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

84-
data.head.push(
85-
// Favicons
86-
makeTag('link', {
84+
// Favicons
85+
if (iconPaths.favicon32 != null) {
86+
data.head.push(makeTag('link', {
8787
rel: 'icon',
8888
type: 'image/png',
8989
sizes: '32x32',
9090
href: getTagHref(publicPath, iconPaths.favicon32, assetsVersionStr)
91-
}),
92-
makeTag('link', {
91+
}))
92+
}
93+
if (iconPaths.favicon16 != null) {
94+
data.head.push(makeTag('link', {
9395
rel: 'icon',
9496
type: 'image/png',
9597
sizes: '16x16',
9698
href: getTagHref(publicPath, iconPaths.favicon16, assetsVersionStr)
97-
}),
99+
}))
100+
}
98101

99-
// Add to home screen for Android and modern mobile browsers
102+
// Add to home screen for Android and modern mobile browsers
103+
data.head.push(
100104
makeTag('link', manifestCrossorigin
101105
? {
102106
rel: 'manifest',
@@ -111,9 +115,11 @@ module.exports = class HtmlPwaPlugin {
111115
makeTag('meta', {
112116
name: 'theme-color',
113117
content: themeColor
114-
}),
118+
})
119+
)
115120

116-
// Add to home screen for Safari on iOS
121+
// Add to home screen for Safari on iOS
122+
data.head.push(
117123
makeTag('meta', {
118124
name: 'apple-mobile-web-app-capable',
119125
content: appleMobileWebAppCapable
@@ -125,22 +131,30 @@ module.exports = class HtmlPwaPlugin {
125131
makeTag('meta', {
126132
name: 'apple-mobile-web-app-title',
127133
content: name
128-
}),
129-
makeTag('link', {
134+
})
135+
)
136+
if (iconPaths.appleTouchIcon != null) {
137+
data.head.push(makeTag('link', {
130138
rel: 'apple-touch-icon',
131139
href: getTagHref(publicPath, iconPaths.appleTouchIcon, assetsVersionStr)
132-
}),
133-
makeTag('link', {
140+
}))
141+
}
142+
if (iconPaths.maskIcon != null) {
143+
data.head.push(makeTag('link', {
134144
rel: 'mask-icon',
135145
href: getTagHref(publicPath, iconPaths.maskIcon, assetsVersionStr),
136146
color: themeColor
137-
}),
147+
}))
148+
}
138149

139-
// Add to home screen for Windows
140-
makeTag('meta', {
150+
// Add to home screen for Windows
151+
if (iconPaths.msTileImage != null) {
152+
data.head.push(makeTag('meta', {
141153
name: 'msapplication-TileImage',
142154
content: getTagHref(publicPath, iconPaths.msTileImage, assetsVersionStr)
143-
}),
155+
}))
156+
}
157+
data.head.push(
144158
makeTag('meta', {
145159
name: 'msapplication-TileColor',
146160
content: msTileColor

0 commit comments

Comments
 (0)