From b229880459ed46c20d50b97f5a2051b7fc3d5dbf Mon Sep 17 00:00:00 2001 From: YuanHuakk <1751826683@qq.com> Date: Tue, 21 Nov 2023 19:12:44 +0800 Subject: [PATCH] =?UTF-8?q?build(custom):=20=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 +++ src/router/index.js | 4 ++-- vite.config.js | 11 +++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.env.development b/.env.development index 9c106c8..00c5979 100644 --- a/.env.development +++ b/.env.development @@ -11,3 +11,6 @@ VITE_USE_PROXY=true VITE_BASE_API='/store' VITE_ADMIN_API='/admin' + +# 是否启用监控 +VITE_SENTRY=false diff --git a/src/router/index.js b/src/router/index.js index a5e1741..2e6606a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,7 +5,7 @@ import { getToken, isNullOrWhitespace } from '@/utils' import { useUserStore, usePermissionStore } from '@/store' import * as Sentry from '@sentry/vue' -const isHash = true +const isHash = false export const router = createRouter({ history: isHash ? createWebHashHistory('/') : createWebHistory('/'), routes: basicRoutes, @@ -15,7 +15,7 @@ export const router = createRouter({ export async function setupRouter(app) { await addDynamicRoutes() setupRouterGuard(router) - if (import.meta.env.VITE_SENTRY) { + if (import.meta.env.VITE_SENTRY === 'true') { Sentry.init({ app, dsn: 'https://aa4308fc56a9d107786b8dbcd2ae56e8@w.huakk.top/13', diff --git a/vite.config.js b/vite.config.js index f11c37a..dcf1473 100644 --- a/vite.config.js +++ b/vite.config.js @@ -11,7 +11,14 @@ export default defineConfig(({ command, mode }) => { const env = loadEnv(mode, process.cwd()) const viteEnv = convertEnv(env) - const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_BASE_API, VITE_ADMIN_API } = viteEnv + const { + VITE_PORT, + VITE_PUBLIC_PATH, + VITE_USE_PROXY, + VITE_BASE_API, + VITE_ADMIN_API, + VITE_SENTRY, + } = viteEnv return { base: VITE_PUBLIC_PATH || '/', @@ -39,7 +46,7 @@ export default defineConfig(({ command, mode }) => { outDir: OUTPUT_DIR || 'dist', reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告 chunkSizeWarningLimit: 1024, // chunk 大小警告的限制(单位kb) - sourcemap: true, + sourcemap: VITE_SENTRY, }, } })