chore: 处理 pre 问题

This commit is contained in:
Apple Sun 2023-05-25 19:15:34 +08:00
parent be50cd53f9
commit e663eb92d4
5 changed files with 33 additions and 3 deletions

View File

@ -16,7 +16,7 @@ VITE_DROP_CONSOLE = true
# API 接口地址
# 如果没有跨域问题,直接在这里配置即可
VITE_GLOB_API_URL =
VITE_GLOB_API_URL = https://development.com
# 图片上传地址
VITE_GLOB_UPLOAD_URL =

28
.env.pre Normal file
View File

@ -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

View File

@ -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 =

View File

@ -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",

View File

@ -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: {