Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow use of full url for pwa manifest and icons #4736

Merged
merged 1 commit into from Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 15 additions & 7 deletions packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js
Expand Up @@ -75,25 +75,25 @@ module.exports = class HtmlPwaPlugin {
rel: 'icon',
type: 'image/png',
sizes: '32x32',
href: `${publicPath}${iconPaths.favicon32}${assetsVersionStr}`
href: getTagHref(publicPath, iconPaths.favicon32, assetsVersionStr)
}),
makeTag('link', {
rel: 'icon',
type: 'image/png',
sizes: '16x16',
href: `${publicPath}${iconPaths.favicon16}${assetsVersionStr}`
href: getTagHref(publicPath, iconPaths.favicon16, assetsVersionStr)
}),

// Add to home screen for Android and modern mobile browsers
makeTag('link', manifestCrossorigin
? {
rel: 'manifest',
href: `${publicPath}${manifestPath}${assetsVersionStr}`,
href: getTagHref(publicPath, manifestPath, assetsVersionStr),
crossorigin: manifestCrossorigin
}
: {
rel: 'manifest',
href: `${publicPath}${manifestPath}${assetsVersionStr}`
href: getTagHref(publicPath, manifestPath, assetsVersionStr)
}
),
makeTag('meta', {
Expand All @@ -116,18 +116,18 @@ module.exports = class HtmlPwaPlugin {
}),
makeTag('link', {
rel: 'apple-touch-icon',
href: `${publicPath}${iconPaths.appleTouchIcon}${assetsVersionStr}`
href: getTagHref(publicPath, iconPaths.appleTouchIcon, assetsVersionStr)
}),
makeTag('link', {
rel: 'mask-icon',
href: `${publicPath}${iconPaths.maskIcon}${assetsVersionStr}`,
href: getTagHref(publicPath, iconPaths.maskIcon, assetsVersionStr),
color: themeColor
}),

// Add to home screen for Windows
makeTag('meta', {
name: 'msapplication-TileImage',
content: `${publicPath}${iconPaths.msTileImage}${assetsVersionStr}`
content: getTagHref(publicPath, iconPaths.msTileImage, assetsVersionStr)
}),
makeTag('meta', {
name: 'msapplication-TileColor',
Expand Down Expand Up @@ -170,3 +170,11 @@ function makeTag (tagName, attributes, closeTag = false) {
attributes
}
}

function getTagHref (publicPath, href, assetsVersionStr) {
let tagHref = `${href}${assetsVersionStr}`
if (!(/(http(s?)):\/\//gi.test(href))) {
tagHref = `${publicPath}${tagHref}`
}
return tagHref
}