89 lines
2.2 KiB
JavaScript
89 lines
2.2 KiB
JavaScript
import { fileURLToPath, URL } from "node:url";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
|
|
import { VitePWA } from "vite-plugin-pwa";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import AutoImport from "unplugin-auto-import/vite";
|
|
import Components from "unplugin-vue-components/vite";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
return {
|
|
base: loadEnv(mode, process.cwd())["VITE_DIR"],
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
imports: [
|
|
"vue",
|
|
{
|
|
"naive-ui": [
|
|
"useDialog",
|
|
"useMessage",
|
|
"useNotification",
|
|
"useLoadingBar",
|
|
],
|
|
},
|
|
],
|
|
}),
|
|
Components({
|
|
resolvers: [NaiveUiResolver()],
|
|
}),
|
|
// PWA
|
|
VitePWA({
|
|
registerType: "autoUpdate",
|
|
workbox: {
|
|
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: "今日热榜",
|
|
short_name: "DailyHot",
|
|
description: "汇聚全网热点,热门尽览无余",
|
|
display: "standalone",
|
|
start_url: "/",
|
|
theme_color: "#fff",
|
|
background_color: "#efefef",
|
|
icons: [
|
|
{
|
|
src: "/ico/favicon.png",
|
|
sizes: "200x200",
|
|
type: "image/png",
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
port: 6699,
|
|
},
|
|
build: {
|
|
minify: "terser",
|
|
terserOptions: {
|
|
compress: {
|
|
pure_funcs: ["console.log"],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|