-
Notifications
You must be signed in to change notification settings - Fork 3
/
config-overrides.js
35 lines (33 loc) · 955 Bytes
/
config-overrides.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const {rewireWorkboxGenerate, defaultGenerateConfig} = require('react-app-rewire-workbox');
module.exports = function override(config, env) {
if (env === "production") {
console.log("Production build - Adding Workbox for PWAs");
const workboxConfig = {
...defaultGenerateConfig,
runtimeCaching: [
{
urlPattern: /^https:\/\/api\.wordpress\.org\/.+/,
handler: 'networkFirst',
options: {
cacheName: 'wp-org-api',
expiration: {
maxAgeSeconds: 60 * 60 * 24
}
}
},
{
urlPattern: /^https:\/\/cdn\.jsdelivr\.net\/.+/,
handler: 'cacheFirst',
options: {
cacheName: 'jsdelivr',
expiration: {
maxAgeSeconds: 60 * 60 * 24
}
}
}
],
};
config = rewireWorkboxGenerate(workboxConfig)(config, env);
}
return config;
};