Skip to content

Commit

Permalink
feat(pwa): add manifest.json and service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Jun 16, 2021
1 parent 9bf4b08 commit 49a8d01
Show file tree
Hide file tree
Showing 13 changed files with 1,252 additions and 9 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'search',
'watchhistory',
'favorites',
'pwa',
],
],
},
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ The allowed scopes are:
- search
- watchhistory
- favorites
- pwa

### Subject

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
"stylelint-declaration-strict-value": "^1.7.12",
"stylelint-order": "^4.1.0",
"stylelint-scss": "^3.19.0",
"typescript": "^4.2.4"
"typescript": "^4.2.4",
"workbox-webpack-plugin": "^6.1.5"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
Expand Down
Binary file removed public/images/icon-128x128.png
Binary file not shown.
Binary file removed public/images/icon-144x144.png
Binary file not shown.
Binary file removed public/images/icon-152x152.png
Binary file not shown.
Binary file added public/images/icon-24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/icon-256x256.png
Binary file not shown.
Binary file added public/images/icon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@

<!-- Safari web app -->
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="/images/icon-152x152.png">
<link rel="apple-touch-icon" href="/images/icon-192x192.png" sizes="192x192">

<!-- Chrome, Firefox OS and Opera -->
<meta name="theme-color" content="#000000">
<!-- Windows Phone -->
<meta name="msapplication-navbutton-color" content="#000000">
<!-- iOS Safari -->
<meta name="apple-mobile-web-app-status-bar-style" content="#000000">

<!-- Manifest -->
<link rel="manifest" href="manifest.json" />
</head>
<body>
<div id="root"></div>
Expand All @@ -50,5 +53,12 @@
}
</script>
<script type="module" src="/dist/index.js"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js');
});
}
</script>
</body>
</html>
30 changes: 30 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "JW Showcase",
"display": "standalone",
"start_url": "/",
"short_name": "JW Showcase",
"theme_color": "#DD0000",
"description": "JW Showcase is an open-source, dynamically generated video website.",
"orientation": "any",
"background_color": "#000",
"related_applications": [],
"prefer_related_applications": false,
"icons": [
{
"src": "images/icon-512x512.png",
"sizes": "512x512"
},
{
"src": "images/icon-192x192.png",
"sizes": "192x192"
},
{
"src": "images/icon-48x48.png",
"sizes": "48x48"
},
{
"src": "images/icon-24x24.png",
"sizes": "24x24"
}
]
}
4 changes: 4 additions & 0 deletions snowpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import("snowpack").SnowpackUserConfig } */
const WorkboxPlugin = require('workbox-webpack-plugin');

module.exports = {
mount: {
public: { url: '/', static: true },
Expand Down Expand Up @@ -37,6 +39,8 @@ module.exports = {
});
}

config.plugins.push(new WorkboxPlugin.GenerateSW())

return config;
},
}],
Expand Down
Loading

0 comments on commit 49a8d01

Please sign in to comment.