mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-06 16:16:42 +08:00
优化 Vite 配置,添加运行时缓存策略,确保静态资源和图像的高效加载
This commit is contained in:
+24
-1
@@ -34,7 +34,30 @@ export default defineConfig({
|
|||||||
filename: 'service-worker.ts',
|
filename: 'service-worker.ts',
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,jpg,jpeg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,jpg,jpeg}'],
|
||||||
navigateFallbackDenylist: [/.*\/api\/v\d+\/system\/logging.*/],
|
runtimeCaching: [
|
||||||
|
{
|
||||||
|
urlPattern: /\.(?:js|css|html)$/,
|
||||||
|
handler: 'StaleWhileRevalidate',
|
||||||
|
options: {
|
||||||
|
cacheName: 'static-resources',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urlPattern: /\.(?:png|jpg|jpeg|svg|ico)$/,
|
||||||
|
handler: 'CacheFirst',
|
||||||
|
options: {
|
||||||
|
cacheName: 'image-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 50,
|
||||||
|
maxAgeSeconds: 30 * 24 * 60 * 60, // 缓存 30 天
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
navigateFallback: '/index.html', // 确保页面路由正确加载
|
||||||
|
navigateFallbackDenylist: [
|
||||||
|
/.*\/api\/v\d+\/system\/logging.*/,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
injectManifest: {
|
injectManifest: {
|
||||||
rollupFormat: 'iife',
|
rollupFormat: 'iife',
|
||||||
|
|||||||
Reference in New Issue
Block a user