File tree 3 files changed +57
-21
lines changed
packages/@vue/cli-plugin-pwa
generator/template/public
3 files changed +57
-21
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,19 @@ file, or the `"vue"` field in `package.json`.
71
71
72
72
The path of app’s manifest.
73
73
74
+ - ** pwa.manifestOptions**
75
+
76
+ - Default: ` {} `
77
+
78
+ The object will be used to generate the ` manifest.json `
79
+
80
+ If the following attributes are not defined in the object, the options of ` pwa ` or default options will be used instead.
81
+ - name: ` pwa.name `
82
+ - short_name: ` pwa.name `
83
+ - start_url: ` '.' `
84
+ - display: ` 'standalone' `
85
+ - theme_color: ` pwa.themeColor `
86
+
74
87
- ** pwa.iconPaths**
75
88
76
89
- Defaults:
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,7 +7,26 @@ const defaults = {
7
7
appleMobileWebAppCapable : 'no' ,
8
8
appleMobileWebAppStatusBarStyle : 'default' ,
9
9
assetsVersion : '' ,
10
- manifestPath : 'manifest.json'
10
+ manifestPath : 'manifest.json' ,
11
+ manifestOptions : { }
12
+ }
13
+
14
+ const defaultManifest = {
15
+ icons : [
16
+ {
17
+ "src" : "./img/icons/android-chrome-192x192.png" ,
18
+ "sizes" : "192x192" ,
19
+ "type" : "image/png"
20
+ } ,
21
+ {
22
+ "src" : "./img/icons/android-chrome-512x512.png" ,
23
+ "sizes" : "512x512" ,
24
+ "type" : "image/png"
25
+ }
26
+ ] ,
27
+ start_url : '.' ,
28
+ display : 'standalone' ,
29
+ background_color : "#000000"
11
30
}
12
31
13
32
const defaultIconPaths = {
@@ -109,6 +128,30 @@ module.exports = class HtmlPwaPlugin {
109
128
110
129
cb ( null , data )
111
130
} )
131
+
132
+
133
+ } )
134
+
135
+ compiler . hooks . emit . tapAsync ( ID , ( data , cb ) => {
136
+ const {
137
+ name,
138
+ themeColor,
139
+ manifestPath,
140
+ manifestOptions
141
+ } = this . options
142
+ const publicOptions = {
143
+ name,
144
+ short_name : name ,
145
+ theme_color : themeColor
146
+ }
147
+ const outputManifest = JSON . stringify (
148
+ Object . assign ( publicOptions , defaultManifest , manifestOptions )
149
+ )
150
+ data . assets [ manifestPath ] = {
151
+ source : ( ) => outputManifest ,
152
+ size : ( ) => outputManifest . length
153
+ }
154
+ cb ( null , data )
112
155
} )
113
156
}
114
157
}
You can’t perform that action at this time.
0 commit comments