From 25880345424f55e1e25dce64ec3ef0635e46b51d Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 22 Aug 2024 11:32:53 +0800 Subject: [PATCH] chore: add debug info Signed-off-by: Innei --- vite.config.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 78072e68b..15f334c62 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,8 +4,9 @@ import { fileURLToPath } from "node:url" import { sentryVitePlugin } from "@sentry/vite-plugin" import react from "@vitejs/plugin-react" +import { cyan, green } from "kolorist" import { visualizer } from "rollup-plugin-visualizer" -import type { PluginOption } from "vite" +import type { PluginOption, ViteDevServer } from "vite" import { defineConfig, loadEnv } from "vite" import mkcert from "vite-plugin-mkcert" @@ -74,6 +75,7 @@ const vite = ({ mode }) => { }, }), + devPrint(), process.env.ANALYZER && visualizer({ open: true }), ], define: { @@ -117,3 +119,18 @@ function htmlPlugin(env: typeof EnvType): PluginOption { }, } } + +const devPrint = (): PluginOption => ({ + name: "dev-print", + configureServer(server: ViteDevServer) { + const _printUrls = server.printUrls + server.printUrls = () => { + _printUrls() + console.info( + ` ${green( + "➜", + )} Online debug: ${cyan("https://web.follow.is/__debug_proxy")}`, + ) + } + }, +})