Skip to content

Commit

Permalink
🏗️ added: workbox sw
Browse files Browse the repository at this point in the history
  • Loading branch information
PiyushSuthar committed Jul 24, 2021
1 parent d90db7d commit 763c751
Show file tree
Hide file tree
Showing 4 changed files with 3,595 additions and 182 deletions.
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
gtag("js", new Date());

gtag("config", "G-4RJJLPN38T");

if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker.register("/sw.js");
});
}
}
</script>
</body>
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
"serve": "vite preview",
"postbuild": "workbox generateSW workbox-config.js"
},
"dependencies": {
"nanostores": "^0.3.3",
Expand All @@ -16,6 +17,7 @@
"@types/react": "^17.0.11",
"typescript": "^4.1.2",
"vite": "^2.2.3",
"vite-plugin-compression": "^0.3.0"
"vite-plugin-compression": "^0.3.0",
"workbox-cli": "^6.1.5"
}
}
5 changes: 5 additions & 0 deletions workbox-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
globDirectory: 'dist/',
globPatterns: ['**/*.{js,css,ico,html,svg,mp3,webp}'],
swDest: 'dist/sw.js',
};
Loading

1 comment on commit 763c751

@vercel
Copy link

@vercel vercel bot commented on 763c751 Jul 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.