forked from NetLogo-Mobile/plweb2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
129 lines (124 loc) · 3.23 KB
/
Copy pathvite.config.ts
File metadata and controls
129 lines (124 loc) · 3.23 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'
import { execSync } from 'child_process'
import { readFileSync } from 'fs'
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
let buildHash = 'unknown'
try {
buildHash = execSync('git rev-parse --short HEAD').toString().trim()
} catch {
// not a git repository or git not available
}
// https://vite.dev/config/
export default defineConfig({
base: './',
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
__BUILD_HASH__: JSON.stringify(buildHash),
},
plugins: [
vue(),
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'sw.ts',
registerType: 'autoUpdate',
injectRegister: null,
devOptions: {
enabled: false,
},
manifest: {
name: 'plweb2',
short_name: 'plweb',
description: 'Physics Lab Web - Online community',
theme_color: '#3397e9',
background_color: '#ffffff',
display: 'standalone',
start_url: '/',
icons: [
{
src: '/assets/icons/logo-192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any maskable',
},
{
src: '/assets/icons/logo-512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
screenshots: [
{
src: '/assets/mobile.png',
sizes: '818x1339',
type: 'image/png',
},
{
src: '/assets/desktop.png',
sizes: '1033x698',
type: 'image/png',
form_factor: 'wide',
},
],
},
injectManifest: {
// Include wasm so the rich-text parser remains available when the app is offline.
globPatterns: ['**/*.{js,css,html,ico,png,svg,jpg,jpeg,webp,wasm}'],
globIgnores: ['assets/icons/logo-192.png', 'assets/icons/logo-512.png'],
},
}),
],
resolve: {
alias: {
'@popup': '/src/services/popup',
'@api': '/src/services/api',
'@storage': '/src/services/storage',
'@services': '/src/services',
'@components': '/src/components',
'@views': '/src/views',
'@i18n': '/src/i18n',
},
},
server: {
host: '0.0.0.0',
proxy: {
// 代理/aliyun-oss
'/static': {
target: 'https://physics-static-cn.turtlesim.com',
changeOrigin: true,
rewrite: (path) => {
return path.replace('/static', '')
},
headers: {
Referer: 'https://www.turtlesim.com/',
},
secure: false, // 关闭 TLS 验证
},
'/api': {
target: 'https://physics-api-cn.turtlesim.com',
changeOrigin: true,
rewrite: (path) => {
console.log(path.replace('/api', ''))
return path.replace('/api', '')
},
headers: {
Referer: 'https://www.turtlesim.com/',
},
},
},
},
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('highlight.js')) {
return 'highlightjs'
}
},
},
},
},
})