You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-5Lines changed: 23 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# vue-cli-plugin-workbox-pwa
2
2
**ALPA**
3
-
A Vue CLI Plugin with advanced support for workbox 6.x and Vue 3. Includes the ability to debug the service worker locally.
3
+
A Vue CLI Plugin with advanced support for workbox 6.x, Vue 3, and webpack 4. Includes the ability to debug the service worker locally.
4
4
5
5
How is this different from the vue-cli-plugin-pwa?
6
6
- vue-cli-plugin-pwa depends on register-service-worker but this does not. The register-service-worker makes several assumptions about how the PWA should work, but this does not meet advanced use cases like cached apis, cache first, etc.
@@ -90,7 +90,7 @@ file, or the `"vue"` field in `package.json`.
90
90
91
91
By default, the start url is set to '/'. If it is set to '.', it will work fine in a web browser or when installed on Windows, but will result in a blank when installed on iOS or Android.
92
92
93
-
The router will alse need to have an entry for `path: '/'`. This will meet the requirements for a good `start_url` in Lighthouse.
93
+
The router will also need to have an entry for `path: '/'`. This will meet the requirements for a good `start_url` in Lighthouse.
94
94
95
95
-**pwa.manifestCrossorigin**
96
96
@@ -178,11 +178,29 @@ vue add workbox-pwa
178
178
Default robots.txt is added.
179
179
- **src/sw.js**
180
180
Default service worker file is added with:
181
-
- common caching scenarios for index.html, css, js, images.
181
+
- Common caching scenarios for index.html, css, js, images.
182
182
- Workbox's syntax for injecting the manifest. `precacheAndRoute(self.__WB_MANIFEST)`
183
183
- Workbox clear cache for outdated versions of Workbox. `cleanupOutdatedCaches()`
184
-
-
185
-
184
+
- **.env**
185
+
- If it doesn't exist, then it's created with the new variable `VUE_APP_PWA_LOCAL_SERVE=false`.
186
+
- If it does, the new variable `VUE_APP_PWA_LOCAL_SERVE=false` is added.
187
+
- This prevents any environments other than pwalocalserve from using that variable.
188
+
- **.env.pwalocalserve**
189
+
- Sets `NODE_ENV=development` so Workbox will allow debugging of the service worker.
190
+
- Sets `VUE_APP_DEBUG=true` so we get Vue debugging.
191
+
- Sets`VUE_APP_PWA_LOCAL_SERVE=true` so we can actually debug the service worker and by passes the "NoopServiceWorker" middleware. Also injects the manifest.
192
+
- **main.js**
193
+
- Adds the import statement to register the service worker and calls the register method.
194
+
- Adds console log statements so you can verify in your browser console that PWA Local Serve is true.
195
+
```
196
+
PWA Local Serve: true
197
+
Node Env: development
198
+
```
199
+
- **service-worker/register-service-worker.js**
200
+
- The code to create an instance of the service worker and register it.
201
+
- Also includes code for updating the service worker:
202
+
- Auto Update - checks for updates to the service worker at an interval. The default is 1 hour.
203
+
- Manual Update - provides a prompt to the user to manually update the app when a new version of the service worker is available. Depending on your caching strategy, you may want to add code to handle things like flushing the cache, unsaved updates (especially if using Offline Cache), etc.
0 commit comments