forked from imsyy/SPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
114 lines (113 loc) · 2.39 KB
/
vite.config.js
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
import {
fileURLToPath,
URL
} from 'node:url'
import {
defineConfig,
loadEnv
} from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {
NaiveUiResolver
} from 'unplugin-vue-components/resolvers'
import {
VitePWA
} from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default ({
mode
}) => defineConfig({
plugins: [vue(), AutoImport({
imports: [
'vue',
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar'
]
}
]
}),
Components({
resolvers: [NaiveUiResolver()]
}),
// PWA
VitePWA({
registerType: 'autoUpdate',
devOptions: {
enabled: true
},
workbox: {
cleanupOutdatedCaches: true,
runtimeCaching: [{
urlPattern: /(.*?)\.(woff2|woff|ttf)/,
handler: 'CacheFirst',
options: {
cacheName: 'file-cache',
},
},
{
urlPattern: /(.*?)\.(webp|png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/,
handler: 'CacheFirst',
options: {
cacheName: 'image-cache',
},
},
],
},
manifest: {
"name": "SPlayer",
"short_name": "SPlayer",
"description": "一个简约的在线音乐播放器",
"display": "standalone",
"start_url": "/",
"theme_color": "#f55e55",
"background_color": "#efefef",
"icons": [{
"src": "/images/logo/favicon.png",
"sizes": "200x200",
"type": "image/png"
}]
}
})
],
server: {
port: 2048,
open: true,
http: true,
ssr: false,
proxy: {
'/api': {
target: loadEnv(mode, process.cwd()).VITE_MUSIC_API,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
},
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "src/style/index.scss";'
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src',
import.meta.url))
}
},
build: {
minify: 'terser',
terserOptions: {
compress: {
// 生产环境时移除 console
pure_funcs: ['console.log'],
},
},
},
})