Skip to content

Commit

Permalink
Remove eleventy-plugin-pwa-v2 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwojcik authored Aug 4, 2024
1 parent 34dd676 commit afc2e78
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 66 deletions.
30 changes: 1 addition & 29 deletions _11ty/plugins.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const { IS_PRODUCTION } = require('./constants');
const siteConfig = require('../content/_data/siteConfig');
const pluginRss = require('@11ty/eleventy-plugin-rss');
const { EleventyHtmlBasePlugin } = require('@11ty/eleventy');
const pluginEmoji = require('eleventy-plugin-emoji');
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation');
const srcSet = require('./plugins/srcset');
const pluginPWA = require('eleventy-plugin-pwa-v2');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');

const productionPlugins = IS_PRODUCTION
Expand All @@ -16,32 +14,6 @@ const productionPlugins = IS_PRODUCTION
]
: [];

const pwaPluginConfig = siteConfig.enablePWA
? [
{
body: pluginPWA,
options: {
cacheId: siteConfig.site.title,
runtimeCaching: [
{
urlPattern: /\/$/,
handler: 'NetworkFirst',
},
{
urlPattern: /\.html$/,
handler: 'NetworkFirst',
},
{
urlPattern:
/^.*\.(jpg|png|mp4|gif|webp|ico|svg|woff2|woff|eot|ttf|otf|ttc|json)$/,
handler: 'StaleWhileRevalidate',
},
],
},
},
]
: [];

const plugins = [
{
body: EleventyHtmlBasePlugin,
Expand All @@ -60,4 +32,4 @@ const plugins = [
},
];

module.exports = [...plugins, ...pwaPluginConfig, ...productionPlugins];
module.exports = [...plugins, ...productionPlugins];
1 change: 0 additions & 1 deletion content/_data/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ module.exports = {
// ---------------------------------------------------------------------------
// Settings for PWA
// ---------------------------------------------------------------------------
enablePWA: false, // If enabled, service worker for PWA will be registered
manifestJson: {
// Language of PWA application
language: 'en-US',
Expand Down
1 change: 0 additions & 1 deletion content/_includes/partials/head.njk
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
{% include "partials/head/title.njk" %}
{% include "partials/head/styles.njk" %}
{% include "partials/head/scripts.njk" %}
{% include "partials/head/service-worker.njk" %}
{% include "partials/head/description.njk" %}
{% include "partials/head/canonical.njk" %}
{% include "partials/head/generator.njk" %}
Expand Down
33 changes: 0 additions & 33 deletions content/_includes/partials/head/service-worker.njk
Original file line number Diff line number Diff line change
@@ -1,33 +0,0 @@
{% if siteConfig.enablePWA %}
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
registration.addEventListener('updatefound', () => {
const newWorker = registration.installing;
newWorker.addEventListener('statechange', () => {
if (newWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
window.location.reload();
}
}
});
});
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
}
</script>
{% else %}
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
registration.unregister();
}
});
}
</script>
{% endif %}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"cross-env": "^7.0.3",
"crypto-js": "^4.2.0",
"eleventy-plugin-emoji": "^1.1.0",
"eleventy-plugin-pwa-v2": "^1.0.1",
"eslint": "^9.0.0",
"eslint": "^8.0.0",
"eslint-plugin-import": "^2.29.1",
"html-minifier-terser": "^7.2.0",
"jsdom": "^24.0.0",
Expand Down

0 comments on commit afc2e78

Please sign in to comment.