Skip to content

Commit

Permalink
add config.toml pwa_IGNORE_FILES
Browse files Browse the repository at this point in the history
  • Loading branch information
Jieiku committed Nov 1, 2024
1 parent 6a2b3fa commit 05a92f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions package_abridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 05a92f2

Please sign in to comment.