Snavigation/vite.config.js

76 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-07-27 09:33:15 +00:00
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
2023-07-27 09:33:15 +00:00
import vue from "@vitejs/plugin-vue";
import path from "path";
2023-08-07 10:09:18 +00:00
import viteCompression from "vite-plugin-compression";
2023-07-27 09:33:15 +00:00
// 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",
},
],
},
}),
2023-08-07 10:09:18 +00:00
// viteCompression
viteCompression(),
],
2023-07-27 09:33:15 +00:00
server: {
host: "0.0.0.0",
port: 5588,
open: true,
},
resolve: {
// 配置路径别名
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
minify: "terser",
terserOptions: {
compress: {
// 生产环境时移除 console
pure_funcs: ["console.log"],
},
},
},
});