From 2fbdde2169158f7e75de26360d6fcda42e7715bc Mon Sep 17 00:00:00 2001 From: CharleeWa <18888351756@163.com> Date: Sat, 10 Dec 2022 22:24:25 +0800 Subject: [PATCH] chore: :whale: update mock logic --- .env.development | 4 +--- .env.production | 2 +- vite.config.ts | 8 ++------ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.env.development b/.env.development index baad08f..19c8495 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,3 @@ VITE_APP_PREVIEW=true VITE_APP_API_BASE_URL=/api -VITE_MOCK=true -VITE_HTTP_MOCK=true - +VITE_HTTP_MOCK=true \ No newline at end of file diff --git a/.env.production b/.env.production index c74e11d..b2daa6a 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,3 @@ NODE_ENV=production VITE_APP_PREVIEW=false -VITE_APP_API_URL=/api +VITE_APP_API_URL=/api \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 62aa641..b45d863 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -21,9 +21,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { const root = process.cwd() const env = loadEnv(mode, root) - const isHttpMock = env.VITE_HTTP_MOCK === 'true' - const isViteMock = env.VITE_MOCK === 'true' - return { base: env.VITE_APP_PUBLIC_PATH, @@ -75,7 +72,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { watch: true, mockUrlList: [/api/], cwd: process.cwd(), - enable: isHttpMock && isViteMock && process.env.NODE_ENV !== 'production', + enable: env.VITE_HTTP_MOCK === 'true' && process.env.NODE_ENV !== 'production', }), ], @@ -106,11 +103,10 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { server: { host: true, port: 3000, - proxy: isHttpMock && isViteMock && process.env.NODE_ENV !== 'production' + proxy: env.VITE_HTTP_MOCK === 'true' ? undefined : { '/api': { - // backend url target: '', ws: false, changeOrigin: true,