forked from imsyy/site-status
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
73 lines (72 loc) · 1.81 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
import { defineConfig, loadEnv } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import react from "@vitejs/plugin-react";
import viteCompression from "vite-plugin-compression";
// https://vitejs.dev/config/
export default ({ mode }) =>
defineConfig({
plugins: [
react(),
// PWA
VitePWA({
registerType: "autoUpdate",
workbox: {
clientsClaim: true,
skipWaiting: true,
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: loadEnv(mode, process.cwd()).VITE_SITE_NAME,
short_name: loadEnv(mode, process.cwd()).VITE_SITE_NAME,
description: loadEnv(mode, process.cwd()).VITE_SITE_DES,
display: "standalone",
start_url: "/",
theme_color: "#fff",
background_color: "#efefef",
icons: [
{
src: "/images/favicon.png",
sizes: "144x144",
type: "image/png",
},
],
},
}),
// viteCompression
viteCompression(),
],
resolve: {
alias: {
"@": "/src",
},
},
server: {
port: 6598,
},
build: {
minify: "terser",
terserOptions: {
compress: {
pure_funcs: ["console.log"],
},
},
sourcemap: false,
},
});