Files
sproutlink/web/vite.config.ts

74 lines
1.9 KiB
TypeScript
Raw Permalink 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';
export default defineConfig({
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate',
/** logo.png 约 3MB+,不预缓存;由网络按需加载 */
includeAssets: ['favicon.ico', 'pwa-192x192.png', 'pwa-512x512.png'],
manifest: {
name: 'SproutLink',
short_name: 'SproutLink',
description: '短链与二维码',
lang: 'zh-CN',
dir: 'ltr',
display: 'standalone',
start_url: '/',
scope: '/',
theme_color: '#fafafa',
background_color: '#fafafa',
orientation: 'portrait-primary',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,woff,ttf}'],
globIgnores: ['**/logo.png'],
maximumFileSizeToCacheInBytes: 3 * 1024 * 1024,
/**
* 不设 navigateFallback同域短链如 /aOzb、POST /aOzb/verify 由 Worker 处理;
* 若用 index.html 兜底会抢走导航请求。静态资源仍由预缓存 + 网络回退提供。
*/
navigateFallback: null,
},
devOptions: {
enabled: false,
},
}),
],
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:8787',
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
sourcemap: false,
},
});