Skip to content

Commit 2fbdde2

Browse files
committed
chore: 🐳 update mock logic
1 parent b4f8466 commit 2fbdde2

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

.env.development

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
VITE_APP_PREVIEW=true
22
VITE_APP_API_BASE_URL=/api
3-
VITE_MOCK=true
4-
VITE_HTTP_MOCK=true
5-
3+
VITE_HTTP_MOCK=true

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
NODE_ENV=production
22
VITE_APP_PREVIEW=false
3-
VITE_APP_API_URL=/api
3+
VITE_APP_API_URL=/api

vite.config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
2121
const root = process.cwd()
2222
const env = loadEnv(mode, root)
2323

24-
const isHttpMock = env.VITE_HTTP_MOCK === 'true'
25-
const isViteMock = env.VITE_MOCK === 'true'
26-
2724
return {
2825
base: env.VITE_APP_PUBLIC_PATH,
2926

@@ -75,7 +72,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
7572
watch: true,
7673
mockUrlList: [/api/],
7774
cwd: process.cwd(),
78-
enable: isHttpMock && isViteMock && process.env.NODE_ENV !== 'production',
75+
enable: env.VITE_HTTP_MOCK === 'true' && process.env.NODE_ENV !== 'production',
7976
}),
8077
],
8178

@@ -106,11 +103,10 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
106103
server: {
107104
host: true,
108105
port: 3000,
109-
proxy: isHttpMock && isViteMock && process.env.NODE_ENV !== 'production'
106+
proxy: env.VITE_HTTP_MOCK === 'true'
110107
? undefined
111108
: {
112109
'/api': {
113-
// backend url
114110
target: '',
115111
ws: false,
116112
changeOrigin: true,

0 commit comments

Comments
 (0)