-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
138 lines (137 loc) · 3.72 KB
/
Copy pathvite.config.ts
File metadata and controls
138 lines (137 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import { visualizer } from 'rollup-plugin-visualizer'
import { VitePWA } from 'vite-plugin-pwa'
export default defineConfig(({ mode }) => ({
plugins: [
vue(),
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'sw.ts',
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'icons/*.svg', 'badge-72x72.svg'],
manifest: {
id: '/?source=pwa',
name: 'DispatchFlow 无人车调度平台',
short_name: 'DispatchFlow',
description: '无人车调度管理平台 — 调度工作台、车辆监控、运营分析',
theme_color: '#0D1117',
background_color: '#0D1117',
display: 'standalone',
orientation: 'any',
start_url: '/workbench',
scope: '/',
categories: ['business', 'productivity', 'utilities'],
lang: 'zh-CN',
icons: [
{
src: '/icons/icon-192x192.svg',
sizes: '192x192',
type: 'image/svg+xml',
purpose: 'any maskable',
},
{
src: '/icons/icon-512x512.svg',
sizes: '512x512',
type: 'image/svg+xml',
purpose: 'any maskable',
},
],
shortcuts: [
{
name: '调度工作台',
short_name: '工作台',
url: '/workbench',
},
{
name: '车辆监控',
short_name: '车辆',
url: '/vehicles',
},
{
name: '运营分析',
short_name: '分析',
url: '/analytics',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2}'],
},
injectManifest: {
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2}'],
},
devOptions: {
// 开发环境禁用 SW 注册,避免 sw.ts 在 dev 下被作为模块加载导致的 MIME 类型错误;
// 生产环境仍通过构建产物正常注册。
enabled: false,
type: 'module',
navigateFallback: 'index.html',
},
}),
mode === 'analyze'
? visualizer({
filename: 'dist/bundle-stats.html',
gzipSize: true,
open: false,
})
: undefined,
].filter(Boolean),
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
'font-family': "'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
},
javascriptEnabled: true,
},
},
},
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
},
},
},
build: {
// P2-3: 构建目标与 sourcemap 配置
target: 'es2020',
sourcemap: mode === 'analyze',
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) {
return
}
if (id.includes('ant-design-vue') || id.includes('@ant-design/icons-vue')) {
return 'antd'
}
if (id.includes('leaflet')) {
return 'leaflet'
}
if (id.includes('@amap/amap-jsapi-loader') || id.includes('amap-jsapi')) {
return 'amap'
}
if (id.includes('@fontsource')) {
return 'fonts'
}
if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
return 'vue-vendor'
}
return 'vendor'
},
},
},
},
}))