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
-`workboxConfig` allows you to override the default Workbox options - see [Overriding Workbox configuration](#overriding-workbox-configuration). For example:
54
+
55
+
```javascript:title=gatsby-config.js
56
+
plugins: [
57
+
{
58
+
resolve:`gatsby-plugin-offline`,
59
+
options: {
60
+
workboxConfig: {
61
+
importWorkboxFrom:`cdn`,
62
+
},
63
+
},
64
+
},
65
+
]
66
+
```
67
+
68
+
## Upgrading from 2.x
69
+
70
+
To upgrade from 2.x to 3.x, move any existing options into the `workboxConfig` option. If you haven't specified any options, you have nothing to do.
71
+
72
+
For example, here is a 2.x config:
73
+
74
+
```javascript
75
+
plugins: [
76
+
{
77
+
resolve:`gatsby-plugin-offline`,
78
+
options: {
79
+
importWorkboxFrom:`cdn`,
80
+
},
81
+
},
82
+
]
83
+
```
84
+
85
+
Here is the equivalent 3.x config:
86
+
87
+
```javascript
88
+
plugins: [
89
+
{
90
+
resolve:`gatsby-plugin-offline`,
91
+
options: {
92
+
workboxConfig: {
93
+
importWorkboxFrom:`cdn`,
94
+
},
95
+
},
96
+
},
97
+
]
98
+
```
99
+
100
+
In version 3, Workbox is also upgraded to version 4 so you may need to update your `workboxConfig` if any of those changes apply to you. Please see the [docs on Google Developers](https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-v3) for more information.
101
+
102
+
## Overriding Workbox configuration
103
+
104
+
When adding this plugin to your `gatsby-config.js`, you can use the option `workboxConfig` to override the default Workbox config. To see the full list of options, see [this article on Google Developers](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config).
105
+
106
+
The default `workboxConfig` is as follows. Note that some of these options are configured automatically, e.g. `globPatterns`. If you're not sure about what all of these options mean, it's best to leave them as-is - otherwise, you may end up causing errors on your site, causing old files to be remain cached, or even breaking offline support.
29
107
30
108
```javascript
31
109
constoptions= {
32
110
importWorkboxFrom:`local`,
33
111
globDirectory: rootDir,
34
112
globPatterns,
35
-
modifyUrlPrefix: {
113
+
modifyURLPrefix: {
36
114
// If `pathPrefix` is configured by user, we should replace
37
115
// the default prefix with `pathPrefix`.
38
116
"/":`${pathPrefix}/`,
39
117
},
40
118
cacheId:`gatsby-plugin-offline`,
41
119
// Don't cache-bust JS or CSS files, and anything in the static directory,
42
120
// since these files have unique URLs and their contents will never change
0 commit comments