build(custom): 环境变量调整

This commit is contained in:
2023-11-21 19:12:44 +08:00
parent f5aa29757e
commit b229880459
3 changed files with 14 additions and 4 deletions

View File

@@ -11,3 +11,6 @@ VITE_USE_PROXY=true
VITE_BASE_API='/store'
VITE_ADMIN_API='/admin'
# 是否启用监控
VITE_SENTRY=false

View File

@@ -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',

View File

@@ -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,
},
}
})