Skip to content

Commit 6996df3

Browse files
BigsonLvrochahaoqunjiang
authored andcommitted
feat(HtmlPwaPlugin): adds 'manifestCrossorigin' option (#3939)
close #3933 (cherry picked from commit 49725b4)
1 parent 7b8a06f commit 6996df3

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const defaults = {
77
appleMobileWebAppCapable: 'no',
88
appleMobileWebAppStatusBarStyle: 'default',
99
assetsVersion: '',
10-
manifestPath: 'manifest.json'
10+
manifestPath: 'manifest.json',
11+
manifestCrossorigin: undefined
1112
}
1213

1314
const defaultIconPaths = {
@@ -42,7 +43,8 @@ module.exports = class HtmlPwaPlugin {
4243
appleMobileWebAppStatusBarStyle,
4344
assetsVersion,
4445
manifestPath,
45-
iconPaths
46+
iconPaths,
47+
manifestCrossorigin
4648
} = this.options
4749
const { publicPath } = compiler.options.output
4850

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

6668
// Add to home screen for Android and modern mobile browsers
67-
makeTag('link', {
68-
rel: 'manifest',
69-
href: `${publicPath}${manifestPath}${assetsVersionStr}`
70-
}),
69+
makeTag('link', manifestCrossorigin
70+
? {
71+
rel: 'manifest',
72+
href: `${publicPath}${manifestPath}${assetsVersionStr}`,
73+
crossorigin: manifestCrossorigin
74+
}
75+
: {
76+
rel: 'manifest',
77+
href: `${publicPath}${manifestPath}${assetsVersionStr}`
78+
}
79+
),
7180
makeTag('meta', {
7281
name: 'theme-color',
7382
content: themeColor

packages/@vue/cli-plugin-pwa/ui.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ module.exports = api => {
7676
description: 'org.vue.pwa.config.pwa.appleMobileWebAppStatusBarStyle.description',
7777
default: 'default',
7878
value: data.vue && data.vue.pwa && data.vue.pwa.appleMobileWebAppStatusBarStyle
79+
},
80+
{
81+
name: 'manifestCrossorigin',
82+
type: 'list',
83+
message: 'org.vue.pwa.config.pwa.manifestCrossorigin.message',
84+
description: 'org.vue.pwa.config.pwa.manifestCrossorigin.description',
85+
default: undefined,
86+
value: data.vue && data.vue.pwa && data.vue.pwa.manifestCrossorigin,
87+
choices: [
88+
{
89+
name: 'none',
90+
value: undefined
91+
},
92+
{
93+
name: 'anonymous',
94+
value: 'anonymous'
95+
},
96+
{
97+
name: 'use-credentials',
98+
value: 'use-credentials'
99+
}
100+
]
79101
}
80102
]
81103
}

packages/@vue/cli-ui/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@
721721
"appleMobileWebAppStatusBarStyle": {
722722
"message": "Apple mobile status bar style",
723723
"description": "Style for the web app status bar on iOS"
724+
},
725+
"manifestCrossorigin": {
726+
"message": "Attribute value for manifest.json link tag's crossorigin attribute",
727+
"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"
724728
}
725729
}
726730
},

0 commit comments

Comments
 (0)