-
Notifications
You must be signed in to change notification settings - Fork 255
/
Copy pathvite.config.ts
102 lines (99 loc) · 2.34 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
import { defineConfig, splitVendorChunkPlugin } from 'vite'
import react from '@vitejs/plugin-react'
import viteEslint from 'vite-plugin-eslint'
import svgr from 'vite-plugin-svgr'
import { VitePWA } from 'vite-plugin-pwa'
import { resolve } from 'path'
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'
const getCache = ({ name, pattern }: any) => ({
urlPattern: pattern,
handler: 'StaleWhileRevalidate' as const,
options: {
cacheName: name,
expiration: {
maxEntries: 100,
maxAgeSeconds: 30 * 24 * 60 * 60 // 30 days
}
}
})
// https://vitejs.dev/config/
export default defineConfig({
base: '/paint-board',
optimizeDeps: {
esbuildOptions: { supported: { bigint: true } }
},
esbuild: {
supported: {
bigint: true
}
},
server: {
host: '0.0.0.0'
},
plugins: [
react(),
viteEslint({
failOnError: false
}),
svgr(),
splitVendorChunkPlugin(),
VitePWA({
registerType: 'autoUpdate',
devOptions: {
enabled: true
},
manifest: {
name: 'PAINT-BOARD',
short_name: 'paint-board',
start_url: '/paint-board/',
display: 'standalone',
background_color: '#eef1ff',
theme_color: '#eef1ff',
icons: [
{
src: '/paint-board/pwa-192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: '/paint-board/pwa-512.png',
sizes: '512x512',
type: 'image/png'
}
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,jpg,svg}'],
runtimeCaching: [
getCache({
pattern: /^https:\/\/raw\.githubusercontent\.com\//,
name: 'github-raw-content'
}),
getCache({
pattern: /^https:\/\/fonts\.googleapis\.com\//,
name: 'google-fonts-stylesheets'
}),
getCache({
pattern: /^https:\/\/fonts\.gstatic\.com\//,
name: 'google-fonts-webfonts'
}),
getCache({
pattern: /^https:\/\/fonts\.font\.im\//,
name: 'font-im'
})
]
}
})
],
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
css: {
postcss: {
plugins: [autoprefixer, tailwindcss]
}
}
})