-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathgenerateManifest.js
89 lines (85 loc) · 2.79 KB
/
generateManifest.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
/* eslint-disable no-undef */
/* eslint-disable camelcase */
import { config } from 'dotenv';
import { writeFileSync } from 'fs';
import path from 'path';
// Load .env.local
config({ path: '.env.local' });
// Determine the output directory based on the environment
const isLocalBuild = process.env.LOCAL_BUILD === 'true';
const outputPath = isLocalBuild
? path.resolve('./site.webmanifest') // Write to the root directory
: path.resolve('./build/site.webmanifest'); // Write to the build directory
const manifest = {
short_name: process.env.MANIFEST_NAME || 'Ambient',
name: process.env.MANIFEST_NAME || 'Ambient',
description:
process.env.MANIFEST_DESCRIPTION ||
'Ambient | Zero-to-One Decentralized Trading Protocol',
id: process.env.MANIFEST_ID || '/',
start_url: '/',
display_override: ['window-controls-overlay', 'fullscreen', 'minimal-ui'],
display: 'fullscreen',
theme_color: process.env.MANIFEST_COLOR || '#7371fc',
background_color: process.env.MANIFEST_COLOR || '#7371fc',
icons: [
{
src: process.env.VITE_SITE_ICON_x48 || 'icons/ambient_icon_x48.png',
sizes: '48x48',
type: 'image/png',
},
{
src: process.env.VITE_SITE_ICON_x72 || 'icons/ambient_icon_x72.png',
sizes: '72x72',
type: 'image/png',
},
{
src: process.env.VITE_SITE_ICON_x96 || 'icons/ambient_icon_x96.png',
sizes: '96x96',
type: 'image/png',
},
{
src:
process.env.VITE_SITE_ICON_x128 ||
'icons/ambient_icon_x128.png',
sizes: '128x128',
type: 'image/png',
},
{
src:
process.env.VITE_SITE_ICON_x192 ||
'icons/ambient_icon_x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any',
},
{
src:
process.env.VITE_SITE_ICON_x512 ||
'icons/ambient_icon_x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
screenshots: [
{
src:
process.env.VITE_SITE_SCREENSHOT_WIDE ||
'screenshots/ambient-screenshot-wide.png',
sizes: '1280x720',
type: 'image/png',
form_factor: 'wide',
},
{
src:
process.env.VITE_SITE_SCREENSHOT_NARROW ||
'screenshots/ambient-screenshot-narrow.png',
sizes: '720x1280',
type: 'image/png',
form_factor: 'narrow',
},
],
};
writeFileSync(outputPath, JSON.stringify(manifest, null, 2));
console.log(`site.webmanifest generated at: ${outputPath}`);