aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJieiku2024-11-01 10:53:06 -0700
committerJieiku2024-11-01 10:53:06 -0700
commit05a92f2ec6e8c86baafc7d970e8c992d395b9691 (patch)
tree549c4a2ac6ccf7a36eec03e010e306aa283921d6
parent6a2b3fa3b882398521afa4c0fb862a286f49f421 (diff)
downloadabridge-05a92f2ec6e8c86baafc7d970e8c992d395b9691.tar.gz
abridge-05a92f2ec6e8c86baafc7d970e8c992d395b9691.tar.bz2
abridge-05a92f2ec6e8c86baafc7d970e8c992d395b9691.zip
add config.toml pwa_IGNORE_FILES
-rw-r--r--config.toml2
-rw-r--r--package_abridge.js9
2 files changed, 9 insertions, 2 deletions
diff --git a/config.toml b/config.toml
index 4e448e7..19559cb 100644
--- a/config.toml
+++ b/config.toml
@@ -262,6 +262,8 @@ pwa_cache_all = true
### List of Files for the PWA to initially Cache, used if pwa_cache_all = false
pwa_BASE_CACHE_FILES = "'/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.min.json'"
+pwa_IGNORE_FILES = ["_headers","sw.min.js","sw.js"]
+#pwa_IGNORE_FILES = ["_headers","sw.min.js","sw.js","android-chrome-192x192.png","android-chrome-512x512.png","apple-touch-icon.png","favicon-16x16.png","favicon-32x32.png","favicon.ico","m48.png","m72.png","m96.png","m128.png","m192.png","m384.png","m512.png","m1024.png","mstile-150x150.png"]
###############################################################################
### Favicons, comment out a line to disable loading some or all of these if needed.
diff --git a/package_abridge.js b/package_abridge.js
index 908c9be..e82eee8 100644
--- a/package_abridge.js
+++ b/package_abridge.js
@@ -30,6 +30,7 @@ const pwa_TTL_LONG = data.extra.pwa_TTL_LONG;
const pwa_TTL_EXEMPT = data.extra.pwa_TTL_EXEMPT;
const pwa_cache_all = data.extra.pwa_cache_all;
const pwa_BASE_CACHE_FILES = data.extra.pwa_BASE_CACHE_FILES;
+const pwa_IGNORE_FILES = data.extra.pwa_IGNORE_FILES;
// This is used to pass arguments to zola via npm, for example:
// npm run abridge -- "--base-url https://abridge.pages.dev"
@@ -159,8 +160,12 @@ async function abridge() {
// format output
item = "/" + file.replace(/index\.html$/i, '');// strip index.html from path
item = item.replace(/\\/g, '/');// replace backslash with forward slash for Windows
- item = item.replace(/^\/sw(\.min)?\.js/i, '');// dont cache service worker
- item = item.replace(/^\/_headers/i, '');// dont cache the cloudflare _headers file
+
+ var arrayLength = pwa_IGNORE_FILES.length;
+ for (var i = 0; i < arrayLength; i++) {
+ regex = new RegExp(`^\/${pwa_IGNORE_FILES[i]}`, `i`);
+ item = item.replace(regex, '');// dont cache files in the pwa_IGNORE_FILES array
+ }
// if formatted output is not empty line then append it to cache var
if (item != '') {// skip empty lines