forked from nullstack/nullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanifest.js
More file actions
41 lines (40 loc) · 1.21 KB
/
manifest.js
File metadata and controls
41 lines (40 loc) · 1.21 KB
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
import {existsSync, readFileSync} from 'fs';
import path from 'path';
import project from './project';
import {generateIntegrity} from './integrities';
import files from './files';
import {cdn} from './links';
export default function generateManifest(server) {
if(files['manifest.json']) return files['manifest.json'];
const file = path.join(__dirname, '../', 'public', 'manifest.json');
if(existsSync(file)) {
return readFileSync(file, 'utf-8');
}
const json = {
"name": project.name,
"short_name": project.shortName || project.name,
"theme_color": project.color,
"background_color": project.backgroundColor || project.color,
"display": project.display,
"orientation": project.orientation,
"scope": project.scope,
"start_url": project.root,
"icons": [],
"splash_pages": null
}
for(const size in project.icons) {
const icon = project.icons[size];
json.icons.push({
"src": cdn(icon),
"sizes": `${size}x${size}`,
"type": "image/png",
"purpose": "maskable any"
});
}
const manifest = JSON.stringify(json);
if(!server.less) {
generateIntegrity('manifest.json', manifest);
}
files['manifest.json'] = manifest;
return manifest;
}