94 lines
3.1 KiB
TypeScript
94 lines
3.1 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
export default defineConfig({
|
|
base: './',
|
|
build: {
|
|
target: 'es2020',
|
|
chunkSizeWarningLimit: 4000
|
|
},
|
|
optimizeDeps: {
|
|
exclude: ['mupdf']
|
|
},
|
|
plugins: [
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
injectRegister: false,
|
|
includeAssets: ['icons/favicon.svg', 'icons/apple-touch-icon.png'],
|
|
manifest: {
|
|
name: '万能看图 · DWG/PDF 浏览',
|
|
short_name: '万能看图',
|
|
description:
|
|
'手机与平板上的 DWG 图纸浏览器,支持模型空间与布局空间、图层控制、测量,以及 PDF / EPUB / XPS / CBZ / 图片阅读。',
|
|
lang: 'zh-CN',
|
|
dir: 'ltr',
|
|
start_url: './',
|
|
scope: './',
|
|
display: 'standalone',
|
|
display_override: ['window-controls-overlay', 'standalone', 'minimal-ui'],
|
|
orientation: 'any',
|
|
background_color: '#0b0e14',
|
|
theme_color: '#0b0e14',
|
|
categories: ['productivity', 'utilities', 'graphics'],
|
|
icons: [
|
|
{ src: 'icons/icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' },
|
|
{ src: 'icons/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' },
|
|
{ src: 'icons/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }
|
|
],
|
|
file_handlers: [
|
|
{
|
|
action: './',
|
|
accept: {
|
|
'application/pdf': ['.pdf'],
|
|
'image/vnd.dwg': ['.dwg'],
|
|
'application/acad': ['.dwg'],
|
|
'application/epub+zip': ['.epub'],
|
|
'application/vnd.ms-xpsdocument': ['.xps'],
|
|
'application/oxps': ['.oxps'],
|
|
'application/vnd.comicbook+zip': ['.cbz'],
|
|
'image/png': ['.png'],
|
|
'image/jpeg': ['.jpg', '.jpeg'],
|
|
'image/gif': ['.gif'],
|
|
'image/bmp': ['.bmp']
|
|
}
|
|
}
|
|
]
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2,wasm}'],
|
|
globIgnores: ['**/vendor/**', '**/samples/**'],
|
|
maximumFileSizeToCacheInBytes: 12 * 1024 * 1024,
|
|
navigateFallback: 'index.html',
|
|
cleanupOutdatedCaches: true,
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: /\/vendor\/mupdf\//,
|
|
handler: 'CacheFirst',
|
|
options: {
|
|
cacheName: 'viewer-engines-v1',
|
|
expiration: { maxEntries: 12, maxAgeSeconds: 60 * 60 * 24 * 365 }
|
|
}
|
|
},
|
|
{
|
|
urlPattern: /\/wasm\//,
|
|
handler: 'CacheFirst',
|
|
options: {
|
|
cacheName: 'viewer-cad-wasm-v1',
|
|
expiration: { maxEntries: 8, maxAgeSeconds: 60 * 60 * 24 * 365 }
|
|
}
|
|
},
|
|
{
|
|
urlPattern: /\/samples\//,
|
|
handler: 'CacheFirst',
|
|
options: {
|
|
cacheName: 'viewer-samples-v1',
|
|
expiration: { maxEntries: 12, maxAgeSeconds: 60 * 60 * 24 * 365 }
|
|
}
|
|
}
|
|
]
|
|
}
|
|
})
|
|
]
|
|
})
|
|
|