diff --git a/.env.development b/.env.development index e272c19..5aaf836 100644 --- a/.env.development +++ b/.env.development @@ -16,7 +16,7 @@ VITE_DROP_CONSOLE = true # API 接口地址 # 如果没有跨域问题,直接在这里配置即可 -VITE_GLOB_API_URL = +VITE_GLOB_API_URL = https://development.com # 图片上传地址 VITE_GLOB_UPLOAD_URL = diff --git a/.env.pre b/.env.pre new file mode 100644 index 0000000..257f53f --- /dev/null +++ b/.env.pre @@ -0,0 +1,28 @@ +# 是否开启mock +VITE_USE_MOCK = true + +# 网站根目录 +VITE_PUBLIC_PATH = / + +# 是否删除console +VITE_DROP_CONSOLE = false + +# API +VITE_GLOB_API_URL = https://pre.com + +# 图片上传地址 +VITE_GLOB_UPLOAD_URL = + +# 图片前缀地址 +VITE_GLOB_IMG_URL = + +# 接口 (api) 前缀 +VITE_GLOB_API_URL_PREFIX = /api + +# 是否启用gzip压缩或brotli压缩 +# 可选: gzip | brotli | none +# 如果你需要多种形式,你可以用','来分隔 +VITE_BUILD_COMPRESS = 'gzip' + +# 使用压缩时是否删除原始文件,默认为false +VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false diff --git a/.env.production b/.env.production index 2fbca97..903dad8 100644 --- a/.env.production +++ b/.env.production @@ -8,7 +8,7 @@ VITE_PUBLIC_PATH = / VITE_DROP_CONSOLE = true # API -VITE_GLOB_API_URL = +VITE_GLOB_API_URL = https://productions.com # 图片上传地址 VITE_GLOB_UPLOAD_URL = diff --git a/package.json b/package.json index cdfeab2..e038639 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "bootstrap": "pnpm install", "serve": "npm run dev", "dev": "vite", + "build:pre": "cross-env NODE_ENV=pre vite build -m pre && esno ./build/script/postBuild.ts", "build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts", "build:no-cache": "pnpm clean:cache && npm run build", "report": "cross-env REPORT=true npm run build", diff --git a/vite.config.ts b/vite.config.ts index 271d4a0..e562e8f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -69,8 +69,9 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { esbuild: { // 使用 esbuild 压缩 剔除 console.log - pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [], + // pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [], // minify: true, // minify: true, 等于 minify: 'esbuild', + drop: VITE_DROP_CONSOLE ? ['debugger', 'console'] : [], }, build: {