Skip to content

Commit

Permalink
feat(HtmlPwaPlugin): adds 'manifestCrossorigin' option (#3939)
Browse files Browse the repository at this point in the history
close #3933

(cherry picked from commit 49725b4)
  • Loading branch information
BigsonLvrocha authored and sodatea committed May 25, 2019
1 parent 7b8a06f commit 6996df3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js
Expand Up @@ -7,7 +7,8 @@ const defaults = {
appleMobileWebAppCapable: 'no',
appleMobileWebAppStatusBarStyle: 'default',
assetsVersion: '',
manifestPath: 'manifest.json'
manifestPath: 'manifest.json',
manifestCrossorigin: undefined
}

const defaultIconPaths = {
Expand Down Expand Up @@ -42,7 +43,8 @@ module.exports = class HtmlPwaPlugin {
appleMobileWebAppStatusBarStyle,
assetsVersion,
manifestPath,
iconPaths
iconPaths,
manifestCrossorigin
} = this.options
const { publicPath } = compiler.options.output

Expand All @@ -64,10 +66,17 @@ module.exports = class HtmlPwaPlugin {
}),

// Add to home screen for Android and modern mobile browsers
makeTag('link', {
rel: 'manifest',
href: `${publicPath}${manifestPath}${assetsVersionStr}`
}),
makeTag('link', manifestCrossorigin
? {
rel: 'manifest',
href: `${publicPath}${manifestPath}${assetsVersionStr}`,
crossorigin: manifestCrossorigin
}
: {
rel: 'manifest',
href: `${publicPath}${manifestPath}${assetsVersionStr}`
}
),
makeTag('meta', {
name: 'theme-color',
content: themeColor
Expand Down
22 changes: 22 additions & 0 deletions packages/@vue/cli-plugin-pwa/ui.js
Expand Up @@ -76,6 +76,28 @@ module.exports = api => {
description: 'org.vue.pwa.config.pwa.appleMobileWebAppStatusBarStyle.description',
default: 'default',
value: data.vue && data.vue.pwa && data.vue.pwa.appleMobileWebAppStatusBarStyle
},
{
name: 'manifestCrossorigin',
type: 'list',
message: 'org.vue.pwa.config.pwa.manifestCrossorigin.message',
description: 'org.vue.pwa.config.pwa.manifestCrossorigin.description',
default: undefined,
value: data.vue && data.vue.pwa && data.vue.pwa.manifestCrossorigin,
choices: [
{
name: 'none',
value: undefined
},
{
name: 'anonymous',
value: 'anonymous'
},
{
name: 'use-credentials',
value: 'use-credentials'
}
]
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions packages/@vue/cli-ui/locales/en.json
Expand Up @@ -721,6 +721,10 @@
"appleMobileWebAppStatusBarStyle": {
"message": "Apple mobile status bar style",
"description": "Style for the web app status bar on iOS"
},
"manifestCrossorigin": {
"message": "Attribute value for manifest.json link tag's crossorigin attribute",
"description": "Value for `crossoriging` attribute in manifest link tag in the generated HTML, you may need to set this if your pwa is behind an authenticated proxy"
}
}
},
Expand Down

0 comments on commit 6996df3

Please sign in to comment.