newgen-pwa-transformer
v0.1.1
Published
Generate and attach a cache-first service worker for a built React/Vite dist folder.
Maintainers
Readme
newgen-pwa-transformer
Generate and attach a cache-first serviceWorker.js for a built React/Vite dist folder.
Install
npm install --save-dev newgen-pwa-transformerUse
Add the command after your app build:
{
"scripts": {
"build": "vite build",
"pwa-tf": "pwa-tf"
}
}Then run:
npm run build
npm run pwa-tfBy default the CLI scans dist, writes dist/serviceWorker.js, and injects a service worker registration script into dist/index.html.
For a different build folder:
npm run pwa-tf -- --dist buildThe generated service worker:
- precaches every static file found in the build folder
- uses a build-content hash in the cache name
- removes older
pwa-tf-*caches on activation - serves cached same-origin
GETrequests first - falls back to cached
index.htmlfor offline SPA navigation
