forked from OSMCha/osmcha-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
87 lines (82 loc) · 1.72 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* config-overrides.js */
const NAVIGATE_FALLBACK_WHITELIST = [
/^(?!.*\.html$|\/data\/|\/admin|\/api-docs|\/api\/).*/
];
const RUNTIME_CACHING = [
{
urlPattern: /\/changesets\/\?page=/,
handler: 'fastest',
options: {
cache: {
maxEntries: 10,
name: 'changesets-page-cache'
}
}
},
{
urlPattern: /\/changesets\/[0-9]+\//,
handler: 'networkFirst',
options: {
cache: {
maxEntries: 10,
name: 'changesets-cache'
}
}
},
{
urlPattern: /s3.amazonaws.com\/mapbox\/real-changesets\/production\//,
handler: 'cacheFirst',
options: {
cache: {
maxEntries: 50,
name: 'cmap-cache'
}
}
},
{
urlPattern: /\/tags\//,
handler: 'fastest',
options: {
cache: {
maxEntries: 2,
name: 'filters-tags-cache'
}
}
},
{
urlPattern: /\/suspicion-reasons\//,
handler: 'fastest',
options: {
cache: {
maxEntries: 2,
name: 'filters-reasons-cache'
}
}
},
{
urlPattern: /osmcha-frontend\/master\/ABOUT/,
handler: 'fastest',
options: {
cache: {
maxEntries: 2,
name: 'about-page-cache'
}
}
}
];
function overrideSWPrecacheWebpackPlugin(config) {
const pluginIndex = config.plugins.findIndex(
x => x.constructor.name === 'SWPrecacheWebpackPlugin'
);
config.plugins[
pluginIndex
].options.navigateFallbackWhitelist = NAVIGATE_FALLBACK_WHITELIST;
config.plugins[pluginIndex].options.runtimeCaching = RUNTIME_CACHING;
return config;
}
module.exports = function override(config, env) {
if (env === 'production') {
config = overrideSWPrecacheWebpackPlugin(config);
}
return config;
};