-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgridsome.client.js
108 lines (93 loc) · 2.66 KB
/
gridsome.client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const { basename, extname } = require('path');
const { register } = require('register-service-worker');
const clientConfig = function (Vue, options, context) {
let { head, isClient } = context;
if (process.env.NODE_ENV === 'production' && isClient) {
register(options.serviceWorkerPath, {
ready() {
console.log('Service worker is active.')
},
registered(registration) {
console.log('Service worker has been registered.')
},
cached(registration) {
console.log('Content has been cached for offline use.')
},
updatefound(registration) {
console.log('New content is downloading.')
},
updated(registration) {
registration.waiting.postMessage({ type: 'SKIP_WAITING' });
console.log('New content is available; please refresh.')
},
offline() {
console.log('No internet connection found. App is running in offline mode.')
},
error(error) {
console.error('Error during service worker registration:', error)
}
})
}
const iconsDir = options.staticAssetsDir;
const iconPathParsed = { name: basename(options.icon), ext: extname(options.icon) };
const msTileImage = `/${iconsDir}${iconPathParsed.name}-144x144${iconPathParsed.ext}`;
head.link.push({
rel: 'manifest',
href: options.manifestPath.replace('\\', '/')
})
if (options.svgFavicon) {
var emptyIcon = head.link.find(x => x.rel === 'icon' && x.href === 'data:,');
if (emptyIcon) {
const index = head.link.indexOf(emptyIcon);
head.link.splice(index, 1);
}
head.link.push({
rel: 'icon',
type: 'image/svg+xml',
href: options.svgFavicon
});
head.link.push({
rel: 'alternate icon',
sizes: 'any',
href: 'favicon.ico',
});
}
if (options.appleMaskIcon && options.appleMaskIconColor) {
head.link.push({
rel: 'mask-icon',
href: options.appleMaskIcon,
color: options.appleMaskIconColor,
})
}
head.meta.push({
name: 'theme-color',
content: options.themeColor
})
head.meta.push({
name: 'apple-mobile-web-app-capable',
content: 'yes'
})
head.meta.push({
name: 'apple-mobile-web-app-status-bar-style',
content: options.statusBarStyle
})
head.meta.push({
name: 'apple-mobile-web-app-title',
content: options.title
})
head.meta.push({
name: 'application-name',
content: options.title
})
if (options.msTileColor) {
head.meta.push({
name: 'msapplication-TileColor',
content: options.msTileColor
})
}
head.meta.push({
name: 'msapplication-TileImage',
content: msTileImage
})
}
export default clientConfig;