Skip to content

Commit

Permalink
Merge pull request #37 from lavas-project/version-5.1.4
Browse files Browse the repository at this point in the history
upgrade to 5.1.4
  • Loading branch information
souldanger authored Jan 3, 2021
2 parents 451e29f + 7f120bf commit 4d92e7b
Show file tree
Hide file tree
Showing 118 changed files with 11,077 additions and 8,272 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ support Workbox V2

# 2.1.1

* [Feature] upgrade Workbox@3.4.1
* [Feature] upgrade Workbox@3.4.1

# 2.2.3

* [Feature] upgrade Workbox@3.6.3

# 5.1.4

* [Feature] upgrade Workbox@5.1.4
* [Fix] deprecated event.initEvent() - thanks to **rdy4ever**
86 changes: 0 additions & 86 deletions MIGRATE.md

This file was deleted.

104 changes: 0 additions & 104 deletions README-v1.md

This file was deleted.

35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ This plugin provides PWA support for Jekyll. Generate a service worker and provi

Google Workbox has already developed a series of [tools](https://developers.google.com/web/tools/workbox/). If you use Webpack or Gulp as your build tool, you can easily generate a service worker with these tools. But in my blog, I don't want to use even npm, and I want to precache recent 10 posts so that they are offline available to visitors even though these posts were never opened by visitors before. That's why I try to integrate this function in Jekyll build process.

**IMPORTANT** This plugin supports Workbox V3 since `v2.0.1`.
If you used `v1.x.x` before, a migration guide is [HERE](./MIGRATE.md).
The API of Workbox V3 has changed a lot compared with V2, some more powerful functions added too.
I really recommend applying an migration.
**IMPORTANT** This plugin supports Workbox V5 since `v5.1.4`.
The API of Workbox V5 has changed a lot compared to previous versions, some more powerful functions added too.

**_PLEASE NOTE -> you must update your service worker as described below!_**

Here's the [v1 Doc](./README-v1.md).

This plugin has been used in [my blog](https://xiaoiver.github.io) so that you can see the effect.

Expand Down Expand Up @@ -82,7 +81,7 @@ precache_glob_patterns | Patterns of precache. [Workbox Config](https://devel
precache_glob_ignores | Ignores of precache. [Workbox Config](https://developers.google.com/web/tools/workbox/get-started/webpack#optional-config)
precache_recent_posts_num | Number of recent posts to precache.

We handle precache and runtime cache with the help of Google Workbox v3.6.3 in service worker.
We handle precache and runtime cache with the help of Google Workbox v5.1.4 in service worker.

### Write your own Service Worker

Expand All @@ -98,34 +97,40 @@ Here's what the `service-worker.js` like in my site.
// set names for both precache & runtime cache
workbox.core.setCacheNameDetails({
prefix: 'my-blog',
suffix: 'v1',
suffix: 'v1.0',
precache: 'precache',
runtime: 'runtime-cache'
});
// let Service Worker take control of pages ASAP
workbox.skipWaiting();
workbox.clientsClaim();
workbox.core.skipWaiting();
workbox.core.clientsClaim();
// let Workbox handle our precache list
workbox.precaching.precacheAndRoute(self.__precacheManifest);
// use `networkFirst` strategy for `*.html`, like all my posts
// use `NetworkFirst` strategy for html
workbox.routing.registerRoute(
/\.html$/,
workbox.strategies.networkFirst()
new workbox.strategies.NetworkFirst()
);

// use `NetworkFirst` strategy for css and js
workbox.routing.registerRoute(
/\.(?:js|css)$/,
new workbox.strategies.NetworkFirst()
);

// use `cacheFirst` strategy for images
// use `CacheFirst` strategy for images
workbox.routing.registerRoute(
/assets\/(img|icons)/,
workbox.strategies.cacheFirst()
new workbox.strategies.CacheFirst()
);

// third party files
// use `StaleWhileRevalidate` third party files
workbox.routing.registerRoute(
/^https?:\/\/cdn.staticfile.org/,
workbox.strategies.staleWhileRevalidate()
new workbox.strategies.StaleWhileRevalidate()
);
```

Expand Down
4 changes: 2 additions & 2 deletions jekyll-pwa-plugin.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'jekyll-pwa-plugin'
s.version = '2.1.1'
s.date = '2018-09-03'
s.version = '5.1.4'
s.date = '2021-01-03'
s.summary = "PWA support for Jekyll."
s.description = "This plugin provides PWA support for Jekyll. Generate a service worker and provides precache with Google Workbox."
s.authors = ["Pan Yuqi"]
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-pwa-plugin.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SWHelper
WORKBOX_VERSION = 'v3.6.3'
WORKBOX_VERSION = 'v5.1.4'
def initialize(site, config)
@site = site
@config = config
Expand Down
Loading

0 comments on commit 4d92e7b

Please sign in to comment.