-
Notifications
You must be signed in to change notification settings - Fork 294
/
vite.config.js
75 lines (74 loc) · 1.72 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
74
75
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import vue from "@vitejs/plugin-vue";
import path from "path";
import viteCompression from "vite-plugin-compression";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
// 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: "Snavigation",
short_name: "Snavigation",
description: "一个极致简约的导航页",
display: "standalone",
start_url: "/",
theme_color: "#fff",
background_color: "#efefef",
icons: [
{
src: "/icon/logo-144.png",
sizes: "144x144",
type: "image/png",
},
],
},
}),
// viteCompression
viteCompression(),
],
server: {
port: 5588,
open: true,
},
resolve: {
// 配置路径别名
alias: {
// eslint-disable-next-line no-undef
"@": path.resolve(__dirname, "./src"),
},
},
build: {
minify: "terser",
terserOptions: {
compress: {
// 生产环境时移除 console
pure_funcs: ["console.log"],
},
},
},
});