-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
131 lines (123 loc) · 3.16 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
131
import { resolve } from 'path';
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import { VitePWA } from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
reactRefresh(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: [
'/src/favicon.svg',
],
mode: 'development',
// filename: 'serviceWorker.ts',
base: '/',
strategies: 'generateSW',
srcDir: 'src',
manifest: {
name: 'Github User Search',
short_name: 'User Search',
theme_color: '#000000',
background_color: "#ffffff",
display: "standalone",
icons: [
{
src: '/assets/favicon.svg', // <== don't remove slash, for testing purposes
sizes: '192x192',
type: 'image/svg',
},
{
src: '/assets/favicon.svg', // <== don't remove slash, for testing purposes
sizes: '512x512',
type: 'image/svg',
},
{
src: '/assets/favicon.svg', // <== don't remove slash, for testing purposes
sizes: '512x512',
type: 'image/svg',
purpose: 'any maskable',
},
],
},
workbox: {
runtimeCaching: [{
// Match any request that ends with .png, .jpg, .jpeg or .svg.
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
// Apply a cache-first strategy.
handler: 'CacheFirst',
options: {
// Use a custom cache name.
cacheName: 'images',
// Only cache 50 images.
expiration: {
maxEntries: 50,
},
},
},
{
// Match any request that ends with .png, .jpg, .jpeg or .svg.
urlPattern: /^.+?avatars\.githubusercontent\.com.+?$/,
// Apply a cache-first strategy.
handler: 'CacheFirst',
options: {
// Use a custom cache name.
cacheName: 'gh-avatars',
// Only cache 10 images.
expiration: {
maxEntries: 1500,
},
},
}],
// workbox options for generateSW
}
})
],
build: {
terserOptions: {
compress: {
passes: 3
}
},
},
// From https://gist.github.com/alexanderniebuhr/12a60bde6faf44d4f519e93b1765ec99
resolve: {
alias: [
{
find: 'octokit/dist-node',
replacement: 'octokit/dist-src',
},
{
find: /@octokit\/(.+)\/dist-node/,
replacement: '@octokit/$1/dist-src',
},
{
find: 'bottleneck/light',
replacement: 'bottleneck/lib',
},
{
find: 'node-fetch',
replacement: resolve('./node-fetch.js'),
},
{
find: 'clean-stack',
replacement: resolve('./clean-stack.js'),
},
]
},
optimizeDeps: {
exclude: [
'octokit',
],
include: [
// 'once',
// 'before-after-hook',
// 'bottleneck/lib',
// 'btoa-lite',
// 'lru-cache',
// 'aggregate-error',
// 'fromentries',
]
}
})