mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-23 09:45:46 +03:00
Use different build path for icons, cache them
This commit is contained in:
parent
19858dc889
commit
7e58a4e14f
2 changed files with 30 additions and 0 deletions
21
public/sw.js
21
public/sw.js
|
@ -33,6 +33,27 @@ const imageRoute = new Route(
|
||||||
);
|
);
|
||||||
registerRoute(imageRoute);
|
registerRoute(imageRoute);
|
||||||
|
|
||||||
|
const iconsRoute = new Route(
|
||||||
|
({ request, sameOrigin }) => {
|
||||||
|
const isIcon = request.url.includes('/icons/');
|
||||||
|
return sameOrigin && isIcon;
|
||||||
|
},
|
||||||
|
new CacheFirst({
|
||||||
|
cacheName: 'icons',
|
||||||
|
plugins: [
|
||||||
|
new ExpirationPlugin({
|
||||||
|
maxEntries: 50,
|
||||||
|
maxAgeSeconds: 3 * 24 * 60 * 60, // 3 days
|
||||||
|
purgeOnQuotaError: true,
|
||||||
|
}),
|
||||||
|
new CacheableResponsePlugin({
|
||||||
|
statuses: [0, 200],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
registerRoute(iconsRoute);
|
||||||
|
|
||||||
// 1-day cache for
|
// 1-day cache for
|
||||||
// - /api/v1/instance
|
// - /api/v1/instance
|
||||||
// - /api/v1/custom_emojis
|
// - /api/v1/custom_emojis
|
||||||
|
|
|
@ -94,6 +94,15 @@ export default defineConfig({
|
||||||
main: resolve(__dirname, 'index.html'),
|
main: resolve(__dirname, 'index.html'),
|
||||||
compose: resolve(__dirname, 'compose/index.html'),
|
compose: resolve(__dirname, 'compose/index.html'),
|
||||||
},
|
},
|
||||||
|
output: {
|
||||||
|
chunkFileNames: (chunkInfo) => {
|
||||||
|
const { facadeModuleId } = chunkInfo;
|
||||||
|
if (facadeModuleId && facadeModuleId.includes('icon')) {
|
||||||
|
return 'assets/icons/[name]-[hash].js';
|
||||||
|
}
|
||||||
|
return 'assets/[name]-[hash].js';
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue