feat: support some configurations through the .env file

This commit is contained in:
vince
2024-07-09 23:43:08 +08:00
parent 2731a1ec96
commit 2406ca832b
10 changed files with 50 additions and 19 deletions

View File

@@ -4,3 +4,5 @@ VITE_PUBLIC_PATH = /
# Basic interface address SPA
VITE_GLOB_API_URL=/api
VITE_VISUALIZER = true

View File

@@ -2,4 +2,8 @@
VITE_PUBLIC_PATH = /
# Basic interface address SPA
VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
VITE_GLOB_API_URL = https://mock-napi.vben.pro/api
VITE_COMPRESS = gzip
VITE_PWA = false

View File

@@ -17,6 +17,7 @@
"type": "module",
"scripts": {
"build": "pnpm vite build",
"build:analyze": "pnpm vite build --mode analyze",
"dev": "pnpm vite",
"preview": "vite preview",
"typecheck": "vue-tsc --noEmit --skipLibCheck"

View File

@@ -1,10 +1,11 @@
import { defineConfig } from '@vben/vite-config';
import { defineConfig, loadAndConvertEnv } from '@vben/vite-config';
export default defineConfig({
application: ({ mode }) => {
application: async ({ mode }) => {
const envConfig = await loadAndConvertEnv();
return {
compress: false,
compressTypes: ['brotli', 'gzip'] as const,
...envConfig,
importmap: false,
importmapOptions: {
// 通过 Importmap CDN 方式引入,
@@ -40,7 +41,6 @@ export default defineConfig({
short_name: `Vben Admin Pro ${mode}`,
},
},
visualizer: false,
};
},
vite: {