// Add the script to your 'index.html' and ...
<script>
(function() {
if("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js", {scope: '/'})
.then(() => console.log("Service Worker registered successfully."))
.catch(error => console.log("Service Worker registration failed:", error));
}
})();
</script>
// don't forget that works only in 'https://' or 'localhost:port' mode so
// if you don't run any server like express.js then install:
// "webpack-dev-server" from npm and add the following line to your package.json
// "scripts: { "start:dev": "webpack-dev-server" }
// npm run start:dev
// it will run your app in 'localhost:8080'
// Add the script to your 'index.html' and ...
<script>
(function() {
if("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js", {scope: '/'})
.then(() => console.log("Service Worker registered successfully."))
.catch(error => console.log("Service Worker registration failed:", error));
}
})();
</script>
// don't forget that works only in 'https://' or 'localhost:port' mode so
// if you don't run any server like express.js then install:
// "webpack-dev-server" from npm and add the following line to your package.json
// "scripts: { "start:dev": "webpack-dev-server" }
// npm run start:dev
// it will run your app in 'localhost:8080'