优化环境域名切换

This commit is contained in:
czm 2022-07-31 14:54:34 +08:00
parent 19c266ed4f
commit 9af19370ac
5 changed files with 30 additions and 32 deletions

View File

@ -1,9 +1,10 @@
const path = require('path') const path = require('path')
module.exports = { module.exports = {
env: { env: {
NODE_ENV: '"development"' NODE_ENV: '"development"',
}, },
defineConstants: { defineConstants: {
CURRENT_BASE_URL: '"https://test.zzfzyc.com/lymarket"',
}, },
mini: { mini: {
// optimizeMainPackage: { // optimizeMainPackage: {
@ -14,28 +15,30 @@ module.exports = {
plugin: { plugin: {
install: { install: {
plugin: require('terser-webpack-plugin'), plugin: require('terser-webpack-plugin'),
args: [{ args: [
terserOptions: { {
compress: true, // 默认使用terser压缩 terserOptions: {
// compress: { compress: true, // 默认使用terser压缩
// drop_console: true, // 去掉打印 // compress: {
// }, // 默认使用terser压缩 // drop_console: true, // 去掉打印
// mangle: false, // }, // 默认使用terser压缩
keep_classnames: true, // 不改变class名称 // mangle: false,
keep_fnames: true // 不改变函数名称 keep_classnames: true, // 不改变class名称
} keep_fnames: true, // 不改变函数名称
}] },
} },
} ],
},
},
}) })
} },
}, },
h5: {}, h5: {},
alias: { alias: {
'@': path.resolve(__dirname, '..', 'src'), '@': path.resolve(__dirname, '..', 'src'),
}, },
sass: { sass: {
resource: path.resolve(__dirname, '..', 'src/styles/common.scss') resource: path.resolve(__dirname, '..', 'src/styles/common.scss'),
}, },
// plugins: [ // plugins: [
// '@tarojs/plugin-react-devtools' // '@tarojs/plugin-react-devtools'

View File

@ -3,7 +3,9 @@ module.exports = {
env: { env: {
NODE_ENV: '"pre"', NODE_ENV: '"pre"',
}, },
defineConstants: {}, defineConstants: {
CURRENT_BASE_URL: '"https://pre.zzfzyc.com/lymarket"',
},
mini: { mini: {
optimizeMainPackage: { optimizeMainPackage: {
enable: true, enable: true,

View File

@ -3,7 +3,9 @@ module.exports = {
env: { env: {
NODE_ENV: '"production"', NODE_ENV: '"production"',
}, },
defineConstants: {}, defineConstants: {
CURRENT_BASE_URL: '"https://www.zzfzyc.com/lymarket"',
},
mini: { mini: {
optimizeMainPackage: { optimizeMainPackage: {
enable: true, enable: true,

View File

@ -27,7 +27,8 @@
"dev:qq": "npm run build:qq -- --watch", "dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch", "dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch", "dev:quickapp": "npm run build:quickapp -- --watch",
"build:weapp:pre": "cross-env NODE_ENV=pre taro build --type weapp" "build:weapp:pre": "cross-env NODE_ENV=pre taro build --type weapp",
"dev:weapp:pre": "cross-env NODE_ENV=pre npm run build:weapp -- --watch"
}, },
"browserslist": [ "browserslist": [
"last 3 versions", "last 3 versions",

View File

@ -1,12 +1,4 @@
function BASE_URL_LIST() { export const BASE_URL = CURRENT_BASE_URL
return {
development: `https://test.zzfzyc.com/lymarket`,
production: `https://www.zzfzyc.com/lymarket`,
pre: `https://pre.zzfzyc.com/lymarket`,
}[process.env.NODE_ENV || 'production']
}
export const BASE_URL = BASE_URL_LIST()
// export const BASE_URL = `http://192.168.0.75:50001/lymarket` // export const BASE_URL = `http://192.168.0.75:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket`
// export const BASE_URL = `http://10.0.0.5:50001/lymarket` // export const BASE_URL = `http://10.0.0.5:50001/lymarket`
@ -29,12 +21,10 @@ export const GET_UPLOAD_SIGN = `/upyun/getsign` // 请求签名 url
export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/` export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/`
// cdn // cdn
export const IMG_CND_Prefix = CURRENT_ENV.includes('development') ? 'https://test.cdn.zzfzyc.com' : 'https://cdn.zzfzyc.com' export const IMG_CND_Prefix = CURRENT_ENV.includes('production') ? 'https://cdn.zzfzyc.com' : 'https://test.cdn.zzfzyc.com'
// export const IMG_CND_Prefix = CURRENT_ENV.includes('development') ? 'https://test.cdn.zzfzyc.com' : 'https://www.cdn.zzfzyc.com'
//在线支付图片baseUrl //在线支付图片baseUrl
export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development') ? 'https://test.zzfzyc.com' : 'https://www.zzfzyc.com' export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('production') ? 'https://www.zzfzyc.com' : 'https://test.zzfzyc.com'
// export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development') ? 'https://test.zzfzyc.com' : 'https://www.zzfzyc.com'
// 上传图片视频 // 上传图片视频
export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}` export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`