Skip to content

Commit ff955c1

Browse files
authored
Add PWA support (#1086)
## Motivation for the change, related issues We want to [make Playground available offline](#133). This PR is a first step and adds support for installing Playground as a PWA. Offline support will be implemented separately. ## Implementation details The PR adds a `manifest.json` file and loads it on the Playground website. This allows browsers to install Playground as a PWA ## Testing Instructions (or ideally a Blueprint) - Checkout this branch - Open Playground in [a browser that supports PWA installing](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Guides/Making_PWAs_installable#browser_support) - Confirm that you can install Playground as a PWA
1 parent 3e7ef3d commit ff955c1

File tree

8 files changed

+82
-0
lines changed

8 files changed

+82
-0
lines changed

packages/playground/website/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<meta name="viewport" content="width=device-width, initial-scale=1" />
2222
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
2323
<link rel="stylesheet" href="/src/styles.css" />
24+
<link rel="manifest" href="/manifest.json" />
2425
<script
2526
async
2627
src="https://www.googletagmanager.com/gtag/js?id=G-SVTNFCP8T7"
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"theme_color": "#ffffff",
3+
"background_color": "#ffffff",
4+
"display": "standalone",
5+
"scope": "/",
6+
"start_url": "/",
7+
"short_name": "WordPress Playground",
8+
"description": "WordPress Playground",
9+
"name": "WordPress Playground",
10+
"icons": [
11+
{
12+
"src": "/website-server/logo-192.png",
13+
"sizes": "192x192",
14+
"type": "image/png"
15+
},
16+
{
17+
"src": "/website-server/logo-256.png",
18+
"sizes": "256x256",
19+
"type": "image/png"
20+
},
21+
{
22+
"src": "/website-server/logo-384.png",
23+
"sizes": "384x384",
24+
"type": "image/png"
25+
},
26+
{
27+
"src": "/website-server/logo-512.png",
28+
"sizes": "512x512",
29+
"type": "image/png"
30+
}
31+
]
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"theme_color": "#ffffff",
3+
"background_color": "#ffffff",
4+
"display": "standalone",
5+
"scope": "/",
6+
"start_url": "/",
7+
"short_name": "WordPress Playground",
8+
"description": "WordPress Playground",
9+
"name": "WordPress Playground",
10+
"icons": [
11+
{
12+
"src": "/logo-192.png",
13+
"sizes": "192x192",
14+
"type": "image/png"
15+
},
16+
{
17+
"src": "/logo-256.png",
18+
"sizes": "256x256",
19+
"type": "image/png"
20+
},
21+
{
22+
"src": "/logo-384.png",
23+
"sizes": "384x384",
24+
"type": "image/png"
25+
},
26+
{
27+
"src": "/logo-512.png",
28+
"sizes": "512x512",
29+
"type": "image/png"
30+
}
31+
]
32+
}
21.3 KB
Loading
25.9 KB
Loading
38.9 KB
Loading
40.5 KB
Loading

packages/playground/website/vite.config.ts

+17
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ export default defineConfig(({ command, mode }) => {
146146
}
147147
},
148148
} as Plugin,
149+
/**
150+
* Copy the `manifest.json` file to the `dist/` directory.
151+
*/
152+
{
153+
name: 'manifest-plugin-build',
154+
apply: 'build',
155+
writeBundle({ dir: outputDir }) {
156+
const manifestPath = path('./manifest.production.json');
157+
158+
if (existsSync(manifestPath) && outputDir) {
159+
copyFileSync(
160+
manifestPath,
161+
join(outputDir, 'manifest.json')
162+
);
163+
}
164+
},
165+
} as Plugin,
149166
],
150167

151168
// Configuration for building your library.

0 commit comments

Comments
 (0)