Files
mengyalinkfly/mengyalinkfly-frontend/vite.config.js

67 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate', // 自动更新 Service Worker也可选 'prompt' 提示用户
includeAssets: ['logo.png', 'favicon.ico'],
manifest: {
name: '萌芽短链',
short_name: '萌芽短链',
description: '简单、快速的短链接生成工具',
theme_color: '#1a1a2e',
background_color: '#16213e',
display: 'standalone',
orientation: 'portrait-primary',
scope: '/',
start_url: '/',
lang: 'zh-CN',
icons: [
{
src: '/logo.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any'
},
{
src: '/logo.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable'
}
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
globIgnores: ['**/background/*.png'], // 背景图过大,不预缓存,在线时再加载
runtimeCaching: [
{
urlPattern: /^https?:\/\/.*\/api\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
expiration: { maxEntries: 32, maxAgeSeconds: 60 * 5 },
cacheableResponse: { statuses: [0, 200] },
networkTimeoutSeconds: 10
}
}
]
}
})
],
server: {
host: '0.0.0.0',
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true
}
}
}
})