Add ServiceWorker caching for static assets (#5524)
This commit is contained in:
parent
6705463ed0
commit
0692991b54
2 changed files with 31 additions and 3 deletions
|
@ -48,7 +48,37 @@ module.exports = merge(sharedConfig, {
|
|||
}),
|
||||
new OfflinePlugin({
|
||||
publicPath: publicPath, // sw.js must be served from the root to avoid scope issues
|
||||
caches: { }, // do not cache things, we only use it for push notifications for now
|
||||
caches: {
|
||||
main: [':rest:'],
|
||||
additional: [':externals:'],
|
||||
optional: [
|
||||
'**/locale_*.js', // don't fetch every locale; the user only needs one
|
||||
'**/*_polyfills-*.js', // the user may not need polyfills
|
||||
'**/*.woff2', // the user may have system-fonts enabled
|
||||
// images/audio can be cached on-demand
|
||||
'**/*.png',
|
||||
'**/*.jpg',
|
||||
'**/*.jpeg',
|
||||
'**/*.svg',
|
||||
'**/*.mp3',
|
||||
'**/*.ogg',
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
'/emoji/1f602.svg', // used for emoji picker dropdown
|
||||
'/emoji/sheet.png', // used in emoji-mart
|
||||
],
|
||||
excludes: [
|
||||
'**/*.gz',
|
||||
'**/*.map',
|
||||
'stats.json',
|
||||
'report.html',
|
||||
// any browser that supports ServiceWorker will support woff2
|
||||
'**/*.eot',
|
||||
'**/*.ttf',
|
||||
'**/*-webfont-*.svg',
|
||||
'**/*.woff',
|
||||
],
|
||||
ServiceWorker: {
|
||||
entry: path.join(__dirname, '../../app/javascript/mastodon/service_worker/entry.js'),
|
||||
cacheName: 'mastodon',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue