Skip to content

Commit 49725b4

Browse files
BigsonLvrochahaoqunjiang
authored andcommitted
feat(HtmlPwaPlugin): adds 'manifestCrossorigin' option (#3939)
close #3933
1 parent 0c6085a commit 49725b4

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
@@ -8,7 +8,8 @@ const defaults = {
88
appleMobileWebAppStatusBarStyle: 'default',
99
assetsVersion: '',
1010
manifestPath: 'manifest.json',
11-
manifestOptions: {}
11+
manifestOptions: {},
12+
manifestCrossorigin: undefined
1213
}
1314

1415
const defaultManifest = {
@@ -61,7 +62,8 @@ module.exports = class HtmlPwaPlugin {
6162
appleMobileWebAppStatusBarStyle,
6263
assetsVersion,
6364
manifestPath,
64-
iconPaths
65+
iconPaths,
66+
manifestCrossorigin
6567
} = this.options
6668
const { publicPath } = compiler.options.output
6769

@@ -83,10 +85,17 @@ module.exports = class HtmlPwaPlugin {
8385
}),
8486

8587
// Add to home screen for Android and modern mobile browsers
86-
makeTag('link', {
87-
rel: 'manifest',
88-
href: `${publicPath}${manifestPath}${assetsVersionStr}`
89-
}),
88+
makeTag('link', manifestCrossorigin
89+
? {
90+
rel: 'manifest',
91+
href: `${publicPath}${manifestPath}${assetsVersionStr}`,
92+
crossorigin: manifestCrossorigin
93+
}
94+
: {
95+
rel: 'manifest',
96+
href: `${publicPath}${manifestPath}${assetsVersionStr}`
97+
}
98+
),
9099
makeTag('meta', {
91100
name: 'theme-color',
92101
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)