| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { defineConfig } from "vite";
- import vue from "@vitejs/plugin-vue";
- import { VitePWA } from 'vite-plugin-pwa';
- import { fileURLToPath, URL } from "node:url";
- // https://vite.dev/config/
- export default defineConfig({
- plugins: [
- vue(),
- VitePWA({
- registerType: 'autoUpdate',
- includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'icons/*.png'],
- manifest: {
- name: 'Junma Show',
- short_name: 'Junma',
- description: '在线视频播放平台',
- theme_color: '#10b981',
- background_color: '#0f172a',
- display: 'standalone',
- icons: [
- {
- src: '/vite.svg',
- sizes: 'any',
- type: 'image/svg+xml',
- purpose: 'any maskable'
- }
- ]
- },
- workbox: {
- globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
- runtimeCaching: [
- {
- urlPattern: /^https:\/\/api\./i,
- handler: 'NetworkFirst',
- options: {
- cacheName: 'api-cache',
- expiration: {
- maxEntries: 50,
- maxAgeSeconds: 60 * 60 * 24 // 24 hours
- },
- cacheableResponse: {
- statuses: [0, 200]
- }
- }
- },
- {
- urlPattern: /^https:\/\/.*\.(jpg|jpeg|png|gif|webp)$/i,
- handler: 'CacheFirst',
- options: {
- cacheName: 'images-cache',
- expiration: {
- maxEntries: 100,
- maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
- }
- }
- },
- {
- urlPattern: /^https:\/\/.*\.m3u8$/i,
- handler: 'NetworkOnly',
- options: {
- cacheName: 'video-cache'
- }
- }
- ],
- cleanupOutdatedCaches: true,
- skipWaiting: true,
- clientsClaim: true
- },
- devOptions: {
- enabled: true,
- type: 'module'
- }
- })
- ],
- resolve: {
- alias: {
- "@": fileURLToPath(new URL("./src", import.meta.url)),
- },
- },
- server: {
- port: 5100,
- host: "0.0.0.0",
- open: true,
- cors: true,
- allowedHosts: [
- '.ngrok-free.app',
- '.ngrok-free.dev',
- '.ngrok.io',
- 'localhost'
- ],
- },
- build: {
- rollupOptions: {
- output: {
- manualChunks: {
- // 将 Vue 相关库分离
- "vue-vendor": ["vue", "vue-router"],
- // 将大型页面组件分离
- "video-player": ["./src/views/VideoPlayer.vue"],
- account: ["./src/views/Account.vue"],
- purchased: ["./src/views/Purchased.vue"],
- favorite: ["./src/views/Favorite.vue"],
- // 将布局组件分离
- layout: [
- "./src/components/layout/MainLayout.vue",
- "./src/components/layout/VideoLayout.vue",
- ],
- },
- },
- },
- // 提高警告阈值
- chunkSizeWarningLimit: 1000,
- },
- });
|