forked from pengfu/vue-2048
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
130 lines (129 loc) · 3.23 KB
/
vite.config.ts
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
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import px2rem from 'postcss-plugin-px2rem';
import postcssPresetEnv from 'postcss-preset-env';
import { resolve } from 'path';
import { VitePWA } from 'vite-plugin-pwa';
import legacy from '@vitejs/plugin-legacy';
import clearConsole from 'vite-plugin-clear-console';
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
css: {
postcss: {
plugins: [
postcssPresetEnv(),
px2rem({
rootValue: 16,
propBlackList: ['font-size', 'border', 'border-width'],
exclude: /(node_module)/,
}),
],
},
},
plugins: [
vue(),
legacy({
targets: [
'Android >= 39',
'Chrome >= 50',
'Safari >= 10.1',
'iOS >= 10.3',
'> 1%',
],
}),
VitePWA({
injectRegister: 'auto',
includeManifestIcons: true,
registerType: 'autoUpdate', // 完了,已经部署点开的人更新不了了,,,
includeAssets: ['favicon/*.png'],
manifest: {
name: '小春2048',
short_name: '小春2048',
description: '请小春吃蛋糕',
lang: 'zh-CN',
theme_color: '#62abe9',
icons: [
{
src: '/favicon/apple-touch-icon.png',
sizes: '180x180',
type: 'image/png',
},
{
src: '/favicon/maskable-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'maskable',
},
{
src: '/favicon/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/favicon/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
},
workbox: {
runtimeCaching: [
{
urlPattern: /(.*?)\.(mp4|mp3|wav|ogg)$/i,
handler: 'CacheFirst',
options: {
cacheName: 'multimedia-cache',
},
},
{
urlPattern: /(.*?)\.(woff2?)$/i,
handler: 'CacheFirst',
options: {
cacheName: 'font-cache',
},
},
{
urlPattern: /(ScenarioCharacterNameExcelTable)\.(json)$/i,
handler: 'NetworkFirst',
options: {
cacheName: 'character-config-table',
},
},
{
urlPattern: /(.*?)\.(png|jpe?g|svg|gif|webp|ico|atlas|skel)$/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'image-live2d-cache',
},
},
{
urlPattern: /(.*?)\.(js|css|json)$/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'asset-cache',
},
},
],
},
// uncomment to unregister service worker
selfDestroying: true,
}),
{
...clearConsole(),
apply: 'build',
},
],
build: {
emptyOutDir: true,
minify: 'terser',
terserOptions: {
toplevel: true,
safari10: true,
},
},
});