Skip to content

Commit

Permalink
Exclude /unrestricted/* from being served/cached by the service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Jan 28, 2025
1 parent bd51c1f commit a0f74dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions doc/pwa.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
The _Evento Portal_ is installable and offers a simple offline page when no internet connection is available. We use the [vite-plugin-pwa](https://github.com/vite-pwa/vite-plugin-pwa) that builds on Workbox to achieve this. The configuration is in [vite.config.ts](../vite.config.ts):

- We define the Web Manifest with the appropriate colors and icons.
- The ServiceWorker should pre-cache all necessary assets of the _Evento Portal_ to render the base layout or "shell" (`index.html`, logo, icons and JavaScript files) but not the _apps_' files in `public/apps`.
- When building the application with `npm run build`, the ServiceWorker is generated to `dist/sw.js`, containing the file paths to pre-cache.
- The Service Worker should pre-cache all necessary assets of the _Evento Portal_ to render the base layout or "shell" (`index.html`, logo, icons and JavaScript files) but not the _apps_' files in `public/apps`.
- When building the application with `npm run build`, the Service Worker is generated to `dist/sw.js`, containing the file paths to pre-cache.

## Testing with ServiceWorker
## Testing with Service Worker

To test the _Evento Portal_ with the ServiceWorker locally, you have to serve the app with a valid SSL certificate using the following command (with `browserstack` as `oAuthClientId` in `public/settings.js`):
To test the _Evento Portal_ with the Service Worker locally, you have to serve the app with a valid SSL certificate using the following command (with `browserstack` as `oAuthClientId` in `public/settings.js`):

```
npm run preview:ssl
npm run build && npm run preview:ssl
```

The application is served under https://bs-local.com:3000.
Expand Down
8 changes: 4 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const commonPlugins = [
"icons/apple-touch-icon-180x180.png",
],
workbox: {
// Exclude all files in apps directory from beeing intercepted
// by the service worker
navigateFallbackDenylist: [/^\/apps/],
// Exclude all files in apps/ and unrestricted/ directories from
// beeing intercepted by the service worker
navigateFallbackDenylist: [/^\/apps/, /^\/unrestricted/],

// Define files to be pre-cached (all except the settings files
// & the apps dir)
globIgnores: ["apps/**/*", "settings*.js"],
globIgnores: ["apps/**/*", "settings*.js", "unrestricted/**/*"],
globPatterns: ["**/*{js,css,html,ico,png,svg,woff}"],
},
manifest: {
Expand Down

0 comments on commit a0f74dd

Please sign in to comment.