Skip to content

Commit

Permalink
feat: 添加 ts 类型
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanzhaoyu committed Feb 15, 2023
1 parent 7835740 commit 7930ec5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Glob API URL
VITE_GLOB_API_URL=/api
VITE_APP_API_BASE_URL = https://localhost:3002/

VITE_APP_API_BASE_URL=https://localhost:3002/
2 changes: 1 addition & 1 deletion src/typings/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
/** api url */
readonly VITE_GLOB_API_URL: string;
readonly VITE_APP_API_BASE_URL: string;
}
5 changes: 3 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig((env) => {
const viteEnv = loadEnv(env.mode, process.cwd())
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv

return {
resolve: {
alias: {
Expand All @@ -14,7 +15,7 @@ export default defineConfig((env) => {
server: {
port: 1002,
host: '0.0.0.0',
open: false,
open: true,
proxy: {
'/api': {
target: viteEnv.VITE_APP_API_BASE_URL,
Expand Down

0 comments on commit 7930ec5

Please sign in to comment.