-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvite.config.ts
85 lines (83 loc) · 2.47 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
/* eslint-disable @typescript-eslint/no-explicit-any */
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import htmlEnv from 'vite-plugin-html-env';
import { VitePWA as pwa } from 'vite-plugin-pwa';
import { visualizer } from 'rollup-plugin-visualizer';
const NODE_ENVS: any = process.env || {};
/**
* https://vitejs.dev/config/
*/
export default defineConfig({
base: process.env.VITE_BASE_URL || '/',
plugins: [
svgr({
svgrOptions: {
icon: true,
svgProps: {
className: 'g-icon',
},
},
}),
react(),
htmlEnv({ ...NODE_ENVS }),
visualizer() as any,
pwa({
manifest: {
name: 'Skyline Overlay',
short_name: 'Skyline',
description: 'A modern customizable horizon FFXIV miniparse overlay.',
icons: [{ src: 'favicon.svg', sizes: 'any' }],
theme_color: '#8aa2d3',
},
workbox: {
runtimeCaching: [
// google fonts css
{
urlPattern: /^https?:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'googleapis-fonts-cache',
expiration: { maxEntries: 10, maxAgeSeconds: 604800 }, // only one css loaded
cacheableResponse: { statuses: [0, 200] },
},
},
// google fonts webfonts
{
urlPattern: /^https?:\/\/fonts\.gstatic\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'gstatic-fonts-cache',
expiration: { maxEntries: 1000, maxAgeSeconds: 31536000 }, // google's css has 600+ files
cacheableResponse: { statuses: [0, 200] },
},
},
// misans webfonts
{
urlPattern: /^https?:\/\/.*\/fonts\/misans-.*.woff2.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'misans-fonts-cache',
expiration: { maxEntries: 10, maxAgeSeconds: 31536000 }, // misans only has 3 files
cacheableResponse: { statuses: [0, 200] },
},
},
],
},
}),
],
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
additionalData: `@use './src/scss/variables' as var;`,
},
},
},
build: {
sourcemap: true,
emptyOutDir: true,
target: ['es2020', 'edge88', 'firefox78', 'chrome87', 'safari14'],
},
});